zhukov000

Untitled

Dec 11th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int mod = 112;
  4. int main()
  5. {
  6.   int max_rem[mod] = {};
  7.   int n, mxs = 0, right;
  8.   cin >> n;
  9.   for(int i=0; i<n; ++i)
  10.   {
  11.     int x;
  12.     cin >> x;
  13.     int j = (mod - x % mod) % mod;
  14.     if ( max_rem[j] > x && max_rem[j] + x > mxs )
  15.     {
  16.       mxs = max_rem[j] + x;
  17.       right = x;
  18.     }
  19.     max_rem[x % mod] = max(max_rem[x % mod], x);
  20.   }
  21.   if (mxs == 0) cout << 0;
  22.   else cout << mxs - right << " " << right;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment