Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <fstream>
- #include <vector>
- using namespace std;
- int main()
- {
- ifstream input("C:\\Users\\Максим\\Downloads\\28128_A (4).txt");
- long long int n = 0, now = 0, max1 = 0, max2 = 0, max01 = 0, max02 = 0, s = 0;
- input >> n;
- for (size_t i = 0; i < n; i++)
- {
- input >> now;
- if (now % 3 == 0 && now > max01) {
- if (max01 > max02)
- max02 = max01;
- max01 = now;
- }
- else if (now % 3 == 0 && now > max02) {
- max02 = now;
- }
- if (now % 3 == 1 && now > max1) {
- max1 = now;
- }
- if (now % 3 == 2 && now > max2) {
- max2 = now;
- }
- }
- cout << max(max01 + max02, max2 + max1);
- }
Add Comment
Please, Sign In to add comment