Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <utility>
- #include <fstream>
- #include <vector>
- using namespace std;
- int main()
- {
- ifstream input("C:\\Users\\Максим\\Downloads\\28133_B (1).txt");
- int a = 0, n = 0, ans = 0;
- vector<int> v(121, 0);
- pair<int, int> p = { 0, 0 };
- input >> n;
- for (size_t i = 0; i < n; i++)
- {
- input >> a;
- if (a + v[(120 - a % 120) % 120] > ans && v[(120 - a % 120) % 120] != 0 && v[(120 - a % 120) % 120] > a) {
- ans = a + v[(120 - a % 120) % 120];
- p.first = v[(120 - a % 120) % 120];
- p.second = a;
- }
- if (a > v[a % 120]) {
- v[a % 120] = a;
- }
- }
- cout << p.first << " " << p.second;
- }
- // https://inf-ege.sdamgia.ru/problem?id=28133
RAW Paste Data