Advertisement
deushiro

Untitled

Jun 29th, 2020
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.     int n;
  5.     cin >> n;
  6.     int e19 = 0, o19 = 0, e = 0, o = 0;
  7.     for(int i = 0; i < n; ++i){
  8.         int x;
  9.         cin >> x;
  10.         if(x % 19 == 0){
  11.             if(x % 2 == 0){
  12.                 if(x >= e19){
  13.                     e = max(e19, e);
  14.                     e19 = x;
  15.                 }
  16.                 else{
  17.                     e = max(x, e);
  18.                 }
  19.             }
  20.             else{
  21.                 if(x >= o19){
  22.                     o = max(o19, o);
  23.                     o19 = x;
  24.                 }
  25.                 else{
  26.                     o = max(x, o);
  27.                 }
  28.             }
  29.         }
  30.         else{
  31.             if(x % 2 == 0){
  32.                 e = max(e, x);
  33.             }
  34.             else{
  35.                 o = max(o, x);
  36.             }
  37.         }
  38.     }
  39.     if(e19 * e == 0 &&  o19 * o == 0){
  40.         cout << 0 << " " << 0;
  41.     }
  42.     else{
  43.         if((e19 + e > o19 + o && e19 * e > 0) || (o19 * o == 0)){
  44.             cout << e19 << " " << e;
  45.         }
  46.         else{
  47.             cout << o19 << " " << o;
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement