73102024-01-06 20:28:25anonMexxcpp17Partially correct 92/100115ms32524 KiB
#include <bits/stdc++.h>
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;
int main() {
    FastIO;
    bool ok;
    ll i, j, rs, N;
    cin >> N;
    vector<ll> lucky(N);
    for(i = 0; i < N; i++)
        cin >> lucky[i];
    rs = -1;
    ok = true;
    vector<ll> ans(N);
    stack<ll> free_places;
    for(i = 1; i < N; i++) {
        if(lucky[i] == lucky[i - 1])
            continue;
        if(lucky[i] - lucky[i - 1] > i - rs + free_places.size()) {
            ok = false;
            break;
        }
        for(j = 0; j < min(lucky[i] - lucky[i - 1], i - rs); j++)
            ans[i - j] = j + lucky[i - 1];
        while(j < i - rs)
            free_places.push(i - j++);
        while(j < lucky[i] - lucky[i - 1]) {
            ans[free_places.top()] = j++ + lucky[i - 1];
            free_places.pop();
        }
        rs = i;
    }
    if(ok) {
        cout << "IGEN\n";
        for(const auto &x : ans)
            cout << x << ' ';
        cout << '\n';
    }
    else
        cout << "NEM\n";
    return 0;
}

SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2156 KiB
subtask20/8
3Partially correct3ms2372 KiB
4Partially correct3ms2660 KiB
5Accepted3ms2648 KiB
6Partially correct3ms2868 KiB
7Wrong answer3ms3008 KiB
8Accepted3ms3088 KiB
9Accepted3ms3160 KiB
10Accepted3ms3388 KiB
11Accepted3ms3476 KiB
subtask316/16
12Accepted3ms3484 KiB
13Accepted3ms3632 KiB
14Accepted2ms3456 KiB
15Accepted3ms3460 KiB
16Accepted3ms3596 KiB
subtask432/32
17Accepted4ms4076 KiB
18Accepted4ms3996 KiB
19Accepted4ms4308 KiB
20Accepted4ms4272 KiB
21Accepted4ms4476 KiB
22Accepted4ms4376 KiB
23Accepted3ms4436 KiB
24Accepted3ms4476 KiB
subtask544/44
25Accepted115ms23584 KiB
26Accepted114ms26784 KiB
27Accepted112ms30336 KiB
28Accepted114ms30976 KiB
29Accepted111ms31080 KiB
30Accepted114ms31180 KiB
31Accepted112ms31164 KiB
32Accepted112ms31188 KiB
33Accepted112ms31164 KiB
34Accepted112ms31280 KiB
35Accepted114ms31172 KiB
36Accepted67ms32204 KiB
37Accepted67ms32524 KiB