Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <set>
- using namespace std;
- int main() {
- int K;
- cin >> K;
- long long a[K];
- for (int i = 0; i < K; i++) {
- cin >> a[i];
- }
- set<long long> st;
- long long out[K];
- for (int i = 0; i < K; i++) {
- long long x = a[i];
- while (true) {
- if (st.count(x + 1) || st.count(x + 7)) x++;
- else {
- if (i < 5 || out[i - 5] <= x) break;
- x++;
- }
- }
- st.insert(x + 1); st.insert(x + 7);
- out[i] = x + 7;
- }
- cout << *(--st.end());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment