151B - Phone Numbers - CodeForces Solution


implementation strings *1200

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
using namespace std;
int main()
{

  int n;
  cin>>n;
  string s[n];
  int taxi[n]={};
  int pizza[n]={};
  int cafe[n]={};
  for(int i=0;i<n;i++)
  {
      int hey;
      cin>>hey;
      cin>>s[i];
      for(int j=0;j<hey;j++)
      {
          string friendd;
          cin>>friendd;
          int temp1=int(friendd[0])-48;
          int temp2=int(friendd[1])-48;
          int temp3=int(friendd[3])-48;
          int temp4=int(friendd[4])-48;
          int temp5=int(friendd[6])-48;
          int temp6=int(friendd[7])-48;

          if(temp1==temp2&&temp2==temp3&&temp3==temp4&&temp4==temp5&&temp5==temp6)
            taxi[i]++;
          else if(temp1>temp2&&temp2>temp3&&temp3>temp4&&temp4>temp5&&temp5>temp6)
            pizza[i]++;
          else
            cafe[i]++;


      }


  }

   //For taxi


  cout<<"If you want to call a taxi, you should call: ";
  int maxx=*max_element(taxi,taxi+n);
  int flag=0;
  for(int i=0;i<n;i++)
  {
      if(taxi[i]==maxx&&flag==0)
      {


        cout<<s[i];
        flag++;
      }

       else if(taxi[i]==maxx&&flag!=0)
      {
          cout<<", ";


        cout<<s[i];
        flag++;
      }



  }
  cout<<"."<<endl;


  //For pizza


  cout<<"If you want to order a pizza, you should call: ";
  int maxx1=*max_element(pizza,pizza+n);
  int flag1=0;
  for(int i=0;i<n;i++)
  {
      if(pizza[i]==maxx1&&flag1==0)
      {


        cout<<s[i];
        flag1++;
      }

       else if(pizza[i]==maxx1&&flag1!=0)
      {
          cout<<", ";


        cout<<s[i];
        flag1++;
      }



  }
  cout<<"."<<endl;


  //For Cafe


  cout<<"If you want to go to a cafe with a wonderful girl, you should call: ";
  int maxx2=*max_element(cafe,cafe+n);
  int flag2=0;
  for(int i=0;i<n;i++)
  {
      if(cafe[i]==maxx2&&flag2==0)
      {


        cout<<s[i];
        flag2++;
      }

       else if(cafe[i]==maxx2&&flag2!=0)
      {
          cout<<", ";


        cout<<s[i];
        flag2++;
      }



  }
  cout<<"."<<endl;







}


Comments

Submit
0 Comments
More Questions

1617A - Forbidden Subsequence
914A - Perfect Squares
873D - Merge Sort
1251A - Broken Keyboard
463B - Caisa and Pylons
584A - Olesya and Rodion
799A - Carrot Cakes
1569B - Chess Tournament
1047B - Cover Points
1381B - Unmerge
1256A - Payment Without Change
908B - New Year and Buggy Bot
979A - Pizza Pizza Pizza
731A - Night at the Museum
742A - Arpa’s hard exam and Mehrdad’s naive cheat
1492A - Three swimmers
1360E - Polygon
1517D - Explorer Space
1230B - Ania and Minimizing
1201A - Important Exam
676A - Nicholas and Permutation
431A - Black Square
474B - Worms
987B - High School Become Human
1223A - CME
1658B - Marin and Anti-coprime Permutation
14B - Young Photographer
143A - Help Vasilisa the Wise 2
320A - Magic Numbers
1658A - Marin and Photoshoot