Guest User

Untitled

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