8352022-01-20 11:22:28kicsiboglarKazamatacpp11Time limit exceeded 16/40298ms8968 KiB
#include <iostream>
#include <vector>

#define ll long long 

using namespace std;

ll n, m, i, j, act, last;

int main()
{
    cin >> n;
    vector <ll> x(n, 0);
    vector <bool> seen(n, false);
    for (i = 0; i < n; ++i) cin >> x[i];

    ll db = 0;
    i = 0;
    while (db!=n)
    {
        if (act != 0)
        {
            if (last >= i)
            {
                x[i] = (x[i] + 1) % n;
            }
            else 
            {
                j = 1;
                while (j <= act)
                {
                    x[i] = (x[i] + 1) % n;
                    ++j;
                }
            }
            if (!seen[x[i]])
            {
                seen[x[i]] = true;
                db++;
            }
           
        }
        else if (!seen[x[i]])
        {
            seen[x[i]] = true;
            db++;
        }
        if (seen[i]) ++i;
        else
        {
            last = i;
            act++;
            i = 0;
        }
    }
    cout << act;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base16/40
1Accepted0/02ms1736 KiB
2Time limit exceeded0/0294ms1712 KiB
3Accepted2/21ms2140 KiB
4Accepted2/21ms2148 KiB
5Accepted2/21ms2152 KiB
6Accepted2/21ms2160 KiB
7Accepted2/23ms2176 KiB
8Accepted2/24ms2176 KiB
9Accepted2/24ms2180 KiB
10Accepted2/24ms2180 KiB
11Time limit exceeded0/2296ms2612 KiB
12Time limit exceeded0/2298ms3120 KiB
13Time limit exceeded0/2296ms3700 KiB
14Time limit exceeded0/2273ms4364 KiB
15Time limit exceeded0/2289ms4924 KiB
16Time limit exceeded0/2289ms5432 KiB
17Time limit exceeded0/2268ms6076 KiB
18Time limit exceeded0/2291ms6788 KiB
19Time limit exceeded0/2275ms7380 KiB
20Time limit exceeded0/2284ms7808 KiB
21Time limit exceeded0/2289ms8452 KiB
22Time limit exceeded0/2266ms8968 KiB