bofk

KRSU.7463

Feb 15th, 2023
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <set>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     int K;
  9.     cin >> K;
  10.     long long a[K];
  11.     for (int i = 0; i < K; i++) {
  12.         cin >> a[i];
  13.     }
  14.  
  15.  
  16.     set<long long> st;
  17.     long long out[K];
  18.     for (int i = 0; i < K; i++) {
  19.         long long x = a[i];
  20.         while (true) {
  21.             if (st.count(x + 1) || st.count(x + 7)) x++;
  22.             else {
  23.                 if (i < 5 || out[i - 5] <= x) break;
  24.                 x++;
  25.             }
  26.         }
  27.         st.insert(x + 1); st.insert(x + 7);
  28.         out[i] = x + 7;
  29.     }
  30.  
  31.     cout << *(--st.end());
  32.  
  33.     return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment