Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, a, b, c, max = 0, min_dif = 10001, min_dif_temp = 10001, sum = 0;
- cin >> n;
- while (n) {
- cin >> a >> b >> c;
- if (a >= b and a >= c) {
- max = a;
- if ((max - b) % 4 != 0)
- min_dif_temp = max - b;
- if (((max - c) % 4 != 0) and ((max - c) < min_dif_temp))
- min_dif_temp = max - c;
- }
- else if (b >= a and b >= c) {
- max = b;
- if ((max - a) % 4 != 0)
- min_dif_temp = max - a;
- if (((max - c) % 4 != 0) and ((max - c) < min_dif_temp))
- min_dif_temp = max - c;
- }
- else if (c >= a and c >= b) {
- max = c;
- if ((max - b) % 4 != 0)
- min_dif_temp = max - a;
- if (((max - b) % 4 != 0) and ((max - b) < min_dif_temp))
- min_dif_temp = max - b;
- }
- if (min_dif_temp <= min_dif and min_dif_temp % 4 != 0)
- min_dif = min_dif_temp;
- min_dif_temp = 10001;
- sum += max;
- max = 0;
- n--;
- }
- if (sum % 4 == 0)
- if (min_dif != 10001)
- sum -= min_dif;
- else {
- cout << 0;
- return 0;
- }
- if (sum % 4 == 0)
- cout << 0;
- else
- cout << sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement