75892024-01-09 21:20:27horvathabelKazamatacpp17Wrong answer 2/40101ms13368 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    set<int> key;
    vector<bool> have;
    have.resize(n+1,false);
    vector<int>room;
    for (int i=0; i<n;i++){
        int x;
        cin>>x;
        room.push_back(x);
    }
    int ans=0;
    while (room[0]!=0){
        key.insert(room[0]);
        have[room[0]]=true;
        ans++;
        room[0]++;
        room[0]=room[0]%n;
    }
    for (int i=1; i<n;i++){
        key.insert((room[i]+ans)%n);
        have[(room[i]+ans)%n]=true;
        if (!have[i]){
            ans++;
            for (auto x:key){
                have[(x+ans)%n]=true;
            }
        }
    }
    cout<<ans;
}
SubtaskSumTestVerdictTimeMemory
base2/40
1Accepted0/03ms1848 KiB
2Wrong answer0/039ms6504 KiB
3Accepted2/23ms2488 KiB
4Wrong answer0/23ms2556 KiB
5Wrong answer0/23ms2632 KiB
6Wrong answer0/23ms2872 KiB
7Wrong answer0/23ms2984 KiB
8Wrong answer0/23ms3192 KiB
9Wrong answer0/23ms3276 KiB
10Wrong answer0/23ms3188 KiB
11Wrong answer0/287ms11960 KiB
12Wrong answer0/2100ms11056 KiB
13Wrong answer0/281ms11704 KiB
14Wrong answer0/2101ms11192 KiB
15Wrong answer0/279ms11968 KiB
16Wrong answer0/286ms12580 KiB
17Wrong answer0/290ms13096 KiB
18Wrong answer0/286ms12588 KiB
19Wrong answer0/2101ms11016 KiB
20Wrong answer0/292ms10576 KiB
21Wrong answer0/290ms13368 KiB
22Wrong answer0/286ms10640 KiB