Advertisement
raisul82

UVA 12626 - I ❤ Pizza

Mar 27th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t;
  6. string a,b;
  7. scanf("%d",&t);
  8. getline(cin,b);
  9. while(t-- && getline(cin,a))
  10. {
  11. int A=0,R=0,M=0,G=0,I=0,T=0,pizza=0;
  12. int len=a.size();
  13. for(int i=0; i<len; i++)
  14. {
  15. if(a[i]=='A')
  16. {
  17. A++;
  18. }
  19. else if(a[i]=='R')
  20. {
  21. R++;
  22. }
  23. else if(a[i]=='M')
  24. {
  25. M++;
  26. }
  27. else if(a[i]=='G')
  28. {
  29. G++;
  30. }
  31. else if(a[i]=='I')
  32. {
  33. I++;
  34. }
  35. else if(a[i]=='T')
  36. {
  37. T++;
  38. }
  39.  
  40. }
  41.  
  42. while(len--)
  43. {
  44. if(A>=3 && R>=2 && M>=1 && G>=1 && I>=1 && T>=1)
  45. {
  46. pizza++;
  47. A=A-3;
  48. M=M-1;
  49. R=R-2;
  50. G=G-1;
  51. I=I-1;
  52. T=T-1;
  53. }
  54. else
  55. {
  56. break;
  57. }
  58.  
  59. }
  60.  
  61. printf("%d\n",pizza);
  62. }
  63.  
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement