72692024-01-05 19:19:32anonKazamatacpp17Accepted 40/4032ms5724 KiB
#include <bits/stdc++.h>
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;
int main() {
    FastIO;
    ll i, until, ans, N;
    cin >> N;
    vector<ll> rooms(N);
    for(i = 0; i < N; i++)
        cin >> rooms[i];
    vector<bool> keys(N, false);
    until = 0;
    ans = -1;
    while(until < N) {
        ans++;
        for(i = 0; i <= until; i++)
            keys[(rooms[i] + ans) % N] = true;
        while(keys[until])
            keys[(rooms[++until] + ans) % N] = true;
    }
    cout << ans << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1828 KiB
2Accepted0/014ms3000 KiB
3Accepted2/23ms2500 KiB
4Accepted2/23ms2720 KiB
5Accepted2/23ms2880 KiB
6Accepted2/23ms3212 KiB
7Accepted2/23ms3356 KiB
8Accepted2/23ms3432 KiB
9Accepted2/23ms3588 KiB
10Accepted2/23ms3568 KiB
11Accepted2/228ms5120 KiB
12Accepted2/229ms5076 KiB
13Accepted2/229ms5080 KiB
14Accepted2/229ms5336 KiB
15Accepted2/228ms5540 KiB
16Accepted2/228ms5596 KiB
17Accepted2/226ms5596 KiB
18Accepted2/229ms5724 KiB
19Accepted2/227ms5632 KiB
20Accepted2/229ms5636 KiB
21Accepted2/226ms5632 KiB
22Accepted2/232ms5632 KiB