Showing posts with label medium. Show all posts
Showing posts with label medium. Show all posts

Monday, September 16, 2019

Codeforce A. The Child and Homework

  1. #include< iostream >
  2. #include< cstdio >
  3. #include< algorithm >
  4.  
  5. using namespace std;
  6.  
  7. string o[4];
  8.  
  9. int main() {
  10.  
  11. int maxlength = 0, minlength = 110, maxindex = 0, minindex = 0;
  12.  
  13. int c[4];
  14.  
  15. for (int i = 0; i < 4; i++) {
  16. getline(cin, o[i]);
  17. c[i] = o[i].length() - 2;
  18. }
  19.  
  20. sort(c, c + 4);
  21.  
  22. bool hasMax = c[3] >= c[2] * 2;
  23. bool hasMin = c[0] <= c[1] / 2;
  24.  
  25. if (hasMax == hasMin) {
  26. cout << "C";
  27. } else if (hasMin) {
  28. for (int i = 0; i < 4; i++) {
  29. if (c[0] + 2 == o[i].length()) {
  30. cout << o[i].at(0);
  31. }
  32. }
  33. } else if (hasMax) {
  34. for (int i = 0; i < 4; i++) {
  35. if (c[3] + 2 == o[i].length()) {
  36. cout << o[i].at(0);
  37. }
  38. }
  39. }
  40.  
  41. return 0;
  42. }