Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <algorithm>
- using namespace std;
- int main() {
- int n;
- //C:\Users\misha\Desktop\2281.txt
- string st;
- //string line;
- cin >> st;
- fstream in;
- in.open(st, ios::in);
- //long long int* s = new long long int;
- //long long int a[4];
- //long long int* s = new long long int[1001];
- // string* input = new string[1001];
- in >> n;
- long long int* s = new long long int[n];
- //long long int i = 0;
- for(long long int i = 0; i < n; ++i) {
- in >> s[i];
- }
- in.close();
- //cout << i << endl;
- long long int ma = -2281337228;
- for (long long int j = 0; j < n; ++j)
- {
- for (long long int q = 0; q < n; ++q)
- {
- if (abs(j - q) >= 4 && (s[j] + s[q]) % 2 == 0 && (s[j] + s[q]) > ma)
- ma = s[j] + s[q];
- }
- }
- if (ma != -2281337228)
- cout << ma;
- else
- cout << 0;
- //cout << endl;
- // cout << stoi("");
- }
- //0 1 2 3 4 5 6 7 8 9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement