fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin>>n;
  7. string a[n];
  8. for(int i=0; i<n; i++)
  9. cin>>a[i];
  10. int mxk=0, k=1;
  11. string s=a[0];
  12. for(int i=1; i<n; i++){
  13. if(a[i][0]==a[i-1][0]){
  14. k++;
  15. } else k=1;
  16. if(k>=mxk){
  17. mxk=k;
  18. s=a[i];
  19. } else if (k==mxk){
  20. s=a[i];
  21. }
  22. }
  23. cout<<s<<endl;
  24. }
  25.  
Success #stdin #stdout 0.01s 5312KB
stdin
7
arhimed
computer
contest
informatics
programming
python
team
stdout
python