77402024-01-10 20:09:47horvathabelKazamatacpp17Accepted 40/4083ms10020 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    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/03ms1812 KiB
2Accepted0/037ms5388 KiB
3Accepted2/23ms2240 KiB
4Accepted2/23ms2188 KiB
5Accepted2/23ms2316 KiB
6Accepted2/23ms2404 KiB
7Accepted2/23ms2564 KiB
8Accepted2/23ms2904 KiB
9Accepted2/23ms3228 KiB
10Accepted2/23ms3068 KiB
11Accepted2/278ms9612 KiB
12Accepted2/282ms9804 KiB
13Accepted2/281ms9692 KiB
14Accepted2/279ms9688 KiB
15Accepted2/278ms9968 KiB
16Accepted2/275ms9756 KiB
17Accepted2/275ms9760 KiB
18Accepted2/279ms10012 KiB
19Accepted2/275ms10020 KiB
20Accepted2/283ms9912 KiB
21Accepted2/271ms9908 KiB
22Accepted2/283ms9964 KiB