Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int n, c, k;
- int m;
- cin >> m;
- vector <int> buf(m, 0);
- int s = 0, a1 = 0, a2 = 0;
- cin >> n; // этого нет
- for (int i = 0; i < n; i++) {
- cin >> c;
- if (c % m != 0) {
- k = buf[m - c % m];
- }
- else {
- k = buf[0];
- }
- if (k != 0 && k > c && k + c > s) {
- s = k + c; // error (вместо c стоит s)
- a1 = k;
- a2 = c; // error (вместо c стоит s)
- }
- buf[c % m] = max(buf[c % m], c);
- }
- cout << a1 << " " << a2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement