Advertisement
OMEGAHEAD_MonkoX

Untitled

Nov 11th, 2020
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. int main() {
  8. int n;
  9. //C:\Users\misha\Desktop\2281.txt
  10. string st;
  11. //string line;
  12. cin >> st;
  13. fstream in;
  14. in.open(st, ios::in);
  15. //long long int* s = new long long int;
  16. //long long int a[4];
  17. //long long int* s = new long long int[1001];
  18. // string* input = new string[1001];
  19. in >> n;
  20. long long int* s = new long long int[n];
  21. //long long int i = 0;
  22. for(long long int i = 0; i < n; ++i) {
  23. in >> s[i];
  24. }
  25. in.close();
  26. //cout << i << endl;
  27. long long int ma = -2281337228;
  28. for (long long int j = 0; j < n; ++j)
  29. {
  30. for (long long int q = 0; q < n; ++q)
  31. {
  32. if (abs(j - q) >= 4 && (s[j] + s[q]) % 2 == 0 && (s[j] + s[q]) > ma)
  33. ma = s[j] + s[q];
  34. }
  35. }
  36. if (ma != -2281337228)
  37. cout << ma;
  38. else
  39. cout << 0;
  40. //cout << endl;
  41. // cout << stoi("");
  42. }
  43. //0 1 2 3 4 5 6 7 8 9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement