https://open.kattis.com/problems/ptice
#include<bits/stdc++.h> using namespace std; int n, a, b, c, maX; string s; string A="ABC"; string B="BABC"; string C="CCAABB"; int main(){ while(A.size()<=100) A+=A; while(B.size()<=100) B+=B; while(C.size()<=100) C+=C; cin >> n >> s; for(int i=0; i<n; i++){ if (s[i]==A[i]) a++; if (s[i]==B[i]) b++; if (s[i]==C[i]) c++; maX= max( max(a,b), c ); } cout<<maX<<"\n"; if (a==maX) cout<<"Adrian\n"; if (b==maX) cout<<"Bruno\n"; if (c==maX) cout<<"Goran"; }
Good luck! If you need help please leave a comment :)
No comments:
Post a Comment