Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.  
  6. int n, a, b, c, max = 0, min_dif = 10001, min_dif_temp = 10001, sum = 0;
  7.  
  8. cin >> n;
  9. while (n) {
  10. cin >> a >> b >> c;
  11.  
  12. if (a >= b and a >= c) {
  13. max = a;
  14.  
  15. if ((max - b) % 4 != 0)
  16. min_dif_temp = max - b;
  17. if (((max - c) % 4 != 0) and ((max - c) < min_dif_temp))
  18. min_dif_temp = max - c;
  19.  
  20. }
  21.  
  22. else if (b >= a and b >= c) {
  23. max = b;
  24.  
  25. if ((max - a) % 4 != 0)
  26. min_dif_temp = max - a;
  27. if (((max - c) % 4 != 0) and ((max - c) < min_dif_temp))
  28. min_dif_temp = max - c;
  29. }
  30.  
  31. else if (c >= a and c >= b) {
  32. max = c;
  33.  
  34. if ((max - b) % 4 != 0)
  35. min_dif_temp = max - a;
  36. if (((max - b) % 4 != 0) and ((max - b) < min_dif_temp))
  37. min_dif_temp = max - b;
  38. }
  39.  
  40. if (min_dif_temp <= min_dif and min_dif_temp % 4 != 0)
  41. min_dif = min_dif_temp;
  42.  
  43. min_dif_temp = 10001;
  44. sum += max;
  45. max = 0;
  46. n--;
  47. }
  48.  
  49. if (sum % 4 == 0)
  50. if (min_dif != 10001)
  51. sum -= min_dif;
  52. else {
  53. cout << 0;
  54. return 0;
  55. }
  56.  
  57. if (sum % 4 == 0)
  58. cout << 0;
  59. else
  60. cout << sum;
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement