Advertisement
Guest User

Untitled

a guest
Jul 15th, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6.  
  7.  
  8. int main()
  9. {
  10.     int n, x, i;
  11.     int maxch = 0, maxch33 = 0, maxnech = 0, maxnech33 = 0, maxs = 0, elem1 = 0, elem2 = 0;
  12.     cin >> n;
  13.     for (i = 0; i < n; i++)
  14.     {
  15.         cin >> x;
  16.         if (x % 2 == 0)
  17.         {
  18.             if (x % 33 == 0 && x + maxch > maxs && maxch > 0) {
  19.                 maxs = x + maxch; elem1 = maxch; elem2 = x;
  20.             }
  21.             if (x % 33 != 0 && x + maxch33 > maxs && maxch33 > 0) {
  22.                 maxs = x + maxch33; elem1 = maxch33; elem2 = x;
  23.             }
  24.         }
  25.         if (x % 2 != 0)
  26.         {
  27.             if (x % 33 == 0 && x + maxnech > maxs && maxnech > 0) {
  28.                 maxs = x + maxnech; elem1 = maxnech; elem2 = x;
  29.             }
  30.             if (x % 33 != 0 && x + maxnech33 > maxs && maxnech33 > 0) {
  31.                 maxs = x + maxnech33; elem1 = maxnech33; elem2 = x;
  32.             }
  33.         }
  34.         if (x % 2 == 0 && x > maxch) maxch = x;
  35.         if (x % 2 == 0 && x % 33 == 0 && x > maxch33) maxch33 = x;
  36.         if (x % 2 != 0 && x > maxnech) maxnech = x;
  37.         if (x % 2 != 0 && x % 33 == 0 && x > maxnech33) maxnech33 = x;
  38.     }
  39.     if (maxs > 0) cout << elem1 << " " << elem2;
  40.     else cout << "00";
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement