Advertisement
vafin20

Untitled

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