_takumi

num25

Oct 29th, 2020
904
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n = 0;
  6.     cin >> n;
  7.     vector<int> mod(160);
  8.     vector<int> mod7(160);
  9.     int now = 0;
  10.     while (cin >> now) {
  11.         if (mod7[now % 160] < now && now % 7 == 0) {
  12.             mod7[now % 160] = now;
  13.         }
  14.         else if (mod[now % 160] < now) {
  15.             mod[now % 160] = now;
  16.         }
  17.     }
  18.     int maxmod = mod[distance(begin(mod), max_element(begin(mod), end(mod)))];
  19.     int maxmod7 = mod7[distance(begin(mod7), max_element(begin(mod7), end(mod7)))];
  20.     mod7[distance(begin(mod7), max_element(begin(mod7), end(mod7)))] = 0;
  21.     int maxmod72 = mod7[distance(begin(mod7), max_element(begin(mod7), end(mod7)))];
  22.     if (maxmod + maxmod7 > maxmod7 + maxmod72) {
  23.         cout << maxmod << " " << maxmod7;
  24.     }
  25.     else {
  26.         cout << maxmod7 << " " << maxmod72;
  27.     }
  28.     return 0;
  29. }
RAW Paste Data