Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int N, sum = 0, minr = 10001;
- int x, y;
- cin >> N;
- for (int i = 0; i < N; i++) {
- cin >> x >> y;
- if (x > y) {
- sum += x;
- } else {
- sum += y;
- }
- if (((int)abs(x - y) % 2 == 1) && (abs(x - y) < minr)) {
- minr = abs(x - y);
- }
- }
- if (sum % 2 == 1) {
- cout << sum;
- } else if (sum % 2 == 0 && minr != 10001) {
- cout << sum - minr;
- } else {
- cout << 0;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement