Advertisement
a53

Concurs3

a53
Mar 27th, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. ifstream fin("concurs.in");
  5. ofstream fout("concurs.out");
  6. int C, N, suma, smax, nrmax, v[4], ec, ecmax;
  7. long long x;
  8. int main()
  9. {
  10. int i;
  11. fin>>C;
  12. fin>>N;
  13. for(i=1; i<=N; ++i)
  14. {
  15. fin>>ec>>x;
  16. suma=0;
  17. while(x)
  18. {
  19. if(x%10==0)
  20. {
  21. suma+=10;
  22. x/=100;
  23. }
  24. else
  25. {
  26. suma+=x%10;
  27. x/=10;
  28. }
  29. }
  30. if(suma>smax)
  31. {
  32. smax=suma;
  33. nrmax=1;
  34. }
  35. else if(suma==smax)
  36. nrmax++;
  37. v[ec]+=suma;
  38. if(v[ec]>ecmax)
  39. ecmax=v[ec];
  40. }
  41. if(C==1)
  42. {
  43. fout<<smax<<" "<<nrmax;
  44. return 0;
  45. }
  46. if(ecmax==0)
  47. fout<<"FARA CAMPION";
  48. else
  49. {
  50. for(i=1; i<4; ++i)
  51. if(v[i]==ecmax)
  52. fout<<i<<" ";
  53. fout<<ecmax;
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement