Advertisement
vafin20

11331

Jun 20th, 2020
1,195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n;
  6.     cin >> n; // кол-во
  7.     int x,y;
  8.     int min_r = 10001;
  9.     int sum = 0;
  10.  
  11.     for(int i = 0; i < n; ++i) {
  12.         cin >> x >> y;
  13.         if (x > y) {
  14.             sum += x;
  15.             if (x - y < min_r && (x - y) % 2 != 0) {
  16.                 min_r = x - y;
  17.             }
  18.         }
  19.         else {
  20.             sum += y;
  21.             if (y - x < min_r && (y - x) % 2 != 0)
  22.                 min_r = y - x;
  23.         }
  24.     }
  25.  
  26.     if(sum % 2 == 0) {
  27.         if(min_r != 10001) {
  28.             sum -= min_r;
  29.             cout << sum << endl;
  30.         }
  31.         else {
  32.             cout << "0" << endl;
  33.         }
  34.     }
  35.     else {
  36.         cout << sum << endl;
  37.     }
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement