fork download
  1. import sys
  2.  
  3. n = sys.stdin.readline()
  4. ans = sys.stdin.readline()
  5. n = int(n)
  6.  
  7. listZzikgi = [
  8. "ABC"*34,
  9. "BABC"*25,
  10. "CCAABB"*17
  11. ]
  12.  
  13. listCnt = [0, 0, 0];
  14. listName = ["Adrian", "Bruno", "Goran"]
  15.  
  16. for i in range(n):
  17. if(ans[i] == listZzikgi[0][i]):
  18. listCnt[0] = listCnt[0]+1;
  19. if (ans[i] == listZzikgi[1][i]):
  20. listCnt[1] = listCnt[1]+1;
  21. if (ans[i] == listZzikgi[2][i]):
  22. listCnt[2] = listCnt[2]+1;
  23.  
  24. maxValue = max(listCnt)
  25. print(maxValue)
  26.  
  27. if(listCnt[0] == listCnt[1] and listCnt[1] == listCnt[2]):
  28. for name in listName:
  29. print(name);
  30.  
  31. elif(listCnt[0] == listCnt[1] or listCnt[0] == listCnt[2] or listCnt[1] == listCnt[2]):
  32. for i in range(2):
  33. idx = listCnt.index(maxValue);
  34. print(listName[idx]);
  35. listCnt[idx] = -1;
  36.  
  37.  
  38. else:
  39. print(listName[listCnt.index(maxValue)]);
Success #stdin #stdout 0.02s 9364KB
stdin
5
BAACC
stdout
3
Bruno