_takumi

num27

Oct 18th, 2020 (edited)
583
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n, i, a, b, s = 0, d = 2000000000, c;
  7.     cin >> n;
  8.     for (i = 0; i < n; i++) {
  9.         cin >> a >> b;
  10.         s += min(a, b);
  11.         c = abs(a - b);
  12.         if (c % 3 != 0 && c < d)
  13.             d = c;
  14.     }
  15.     if (s % 3 == 0)
  16.         s -= d;
  17.     cout << s;
  18.     return 0;
  19. }
RAW Paste Data