77412024-01-10 20:11:24horvathabelKazamatacpp17Accepted 40/4059ms11232 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int> room;
    vector<bool> have;
    have.resize(n+1,0);
    set<int> keys;
    for (int i=0; i<n;i++){
        int x;
        cin>>x;
        room.push_back(x);
    }
    int ans=0;
    for (int i=0; i<n;i++){
        int nowkey=room[i]+ans;
        nowkey%=n;
        keys.insert(room[i]);
        have[nowkey]=true;
        while (!have[i]){
            ans++;
            for (int x:keys){
                have[(x+ans)%n]=true;
            }
        }
    }
    cout<<ans<<endl;

}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1824 KiB
2Accepted0/026ms5372 KiB
3Accepted2/23ms2228 KiB
4Accepted2/23ms2444 KiB
5Accepted2/23ms2660 KiB
6Accepted2/23ms2868 KiB
7Accepted2/23ms3248 KiB
8Accepted2/23ms3460 KiB
9Accepted2/23ms3412 KiB
10Accepted2/23ms3676 KiB
11Accepted2/254ms10532 KiB
12Accepted2/257ms10396 KiB
13Accepted2/257ms10692 KiB
14Accepted2/257ms10744 KiB
15Accepted2/254ms10964 KiB
16Accepted2/254ms10920 KiB
17Accepted2/250ms10916 KiB
18Accepted2/256ms11180 KiB
19Accepted2/252ms11208 KiB
20Accepted2/259ms11232 KiB
21Accepted2/248ms11156 KiB
22Accepted2/259ms11156 KiB