Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main() {
- int n, i, a, b, s = 0, d = 2000000000, c;
- cin >> n;
- for (i = 0; i < n; i++) {
- cin >> a >> b;
- s += min(a, b);
- c = abs(a - b);
- if (c % 3 != 0 && c < d)
- d = c;
- }
- if (s % 3 == 0)
- s -= d;
- cout << s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement