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