7592022-01-09 12:37:14vandrasKazamatacpp14Time limit exceeded 0/40328ms1948 KiB
#include <bits/stdc++.h>
using namespace std;

int n, vis[100005];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	vector<int> keys;

	int ans = 0;

	for(int i = 0; i < n; ++i){
		int x; cin >> x;

		if(!vis[(x+ans)%n]) keys.push_back((x+ans)%n);
		vis[(x+ans)%n] = 1;

		while(!vis[i]){
			vector<int> nkeys;
			for(int k : keys){
				if(!vis[(k+1)%n]) nkeys.push_back((k+1)%n);
				vis[(k+1)%n] = 1;
			}
			swap(keys, nkeys);
			keys = nkeys;
			++ans;
		}

	}

	cout << ans << '\n';


	return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Accepted0/02ms1760 KiB
2Time limit exceeded0/0263ms876 KiB
3Time limit exceeded0/2254ms1012 KiB
4Time limit exceeded0/2280ms1016 KiB
5Time limit exceeded0/2256ms956 KiB
6Time limit exceeded0/2259ms1028 KiB
7Time limit exceeded0/2300ms1056 KiB
8Time limit exceeded0/2256ms1064 KiB
9Time limit exceeded0/2250ms1036 KiB
10Time limit exceeded0/2256ms1948 KiB
11Time limit exceeded0/2250ms1096 KiB
12Time limit exceeded0/2328ms1112 KiB
13Time limit exceeded0/2291ms1216 KiB
14Time limit exceeded0/2266ms1048 KiB
15Time limit exceeded0/2289ms1064 KiB
16Time limit exceeded0/2289ms1140 KiB
17Time limit exceeded0/2291ms1160 KiB
18Time limit exceeded0/2252ms1240 KiB
19Time limit exceeded0/2296ms1188 KiB
20Time limit exceeded0/2298ms1204 KiB
21Time limit exceeded0/2296ms1156 KiB
22Time limit exceeded0/2279ms1280 KiB