Advertisement
aayyk

Untitled

Nov 18th, 2020
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. signed main() {
  6.     int n;
  7.     cin >> n;
  8.  
  9.     vector <int> a(n);
  10.     for (int& x : a) {
  11.         cin >> x;
  12.     }
  13.  
  14.     int x, y, ans = 0;
  15.     for (int i = 0; i < n; i++) {
  16.         for (int j = 1; j < n; j++) {
  17.             if (a[i] > a[j]) {
  18.                 if ((a[i] + a[j]) % 120 == 0 && a[i] + a[j] > ans) {
  19.                     x = a[i], y = a[j];
  20.                     ans = a[i] + a[j];
  21.                 }
  22.             }
  23.         }
  24.     }
  25.  
  26.     cout << x << " " << y << endl;
  27.  
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement