Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- const int mod = 112;
- int main()
- {
- int max_rem[mod] = {};
- int n, mxs = 0, right;
- cin >> n;
- for(int i=0; i<n; ++i)
- {
- int x;
- cin >> x;
- int j = (mod - x % mod) % mod;
- if ( max_rem[j] > x && max_rem[j] + x > mxs )
- {
- mxs = max_rem[j] + x;
- right = x;
- }
- max_rem[x % mod] = max(max_rem[x % mod], x);
- }
- if (mxs == 0) cout << 0;
- else cout << mxs - right << " " << right;
- }
Advertisement
Add Comment
Please, Sign In to add comment