#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;
ll i, j, rs, N;
cin >> N;
vector<ll> lucky(N);
for(i = 0; i < N; i++)
cin >> lucky[i];
rs = -1;
vector<ll> ans(N);
stack<ll> free_places;
for(i = 1; i < N; i++) {
if(lucky[i] == lucky[i - 1])
continue;
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]) {
if(free_places.empty()) {
cout << "NEM\n";
return 0;
}
ans[free_places.top()] = j++ + lucky[i - 1];
free_places.pop();
}
rs = i;
}
cout << "IGEN\n";
for(const auto &x : ans)
cout << x << ' ';
cout << '\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2048 KiB | ||||
subtask2 | 0/8 | ||||||
3 | Partially correct | 3ms | 2176 KiB | ||||
4 | Partially correct | 3ms | 2372 KiB | ||||
5 | Accepted | 3ms | 2580 KiB | ||||
6 | Partially correct | 3ms | 2820 KiB | ||||
7 | Wrong answer | 3ms | 3160 KiB | ||||
8 | Accepted | 3ms | 3156 KiB | ||||
9 | Accepted | 3ms | 3256 KiB | ||||
10 | Accepted | 3ms | 3240 KiB | ||||
11 | Wrong answer | 3ms | 3396 KiB | ||||
subtask3 | 0/16 | ||||||
12 | Accepted | 3ms | 3488 KiB | ||||
13 | Accepted | 2ms | 3480 KiB | ||||
14 | Accepted | 3ms | 3484 KiB | ||||
15 | Accepted | 3ms | 3488 KiB | ||||
16 | Wrong answer | 3ms | 3492 KiB | ||||
subtask4 | 0/32 | ||||||
17 | Accepted | 4ms | 3736 KiB | ||||
18 | Accepted | 4ms | 3768 KiB | ||||
19 | Accepted | 4ms | 3764 KiB | ||||
20 | Accepted | 4ms | 3956 KiB | ||||
21 | Accepted | 4ms | 4044 KiB | ||||
22 | Accepted | 4ms | 4044 KiB | ||||
23 | Accepted | 3ms | 4052 KiB | ||||
24 | Wrong answer | 4ms | 4312 KiB | ||||
subtask5 | 0/44 | ||||||
25 | Accepted | 114ms | 20248 KiB | ||||
26 | Accepted | 114ms | 19916 KiB | ||||
27 | Accepted | 112ms | 19844 KiB | ||||
28 | Accepted | 112ms | 20072 KiB | ||||
29 | Accepted | 114ms | 20212 KiB | ||||
30 | Accepted | 114ms | 20244 KiB | ||||
31 | Accepted | 114ms | 20320 KiB | ||||
32 | Accepted | 112ms | 20344 KiB | ||||
33 | Accepted | 112ms | 20264 KiB | ||||
34 | Accepted | 112ms | 20216 KiB | ||||
35 | Accepted | 115ms | 20308 KiB | ||||
36 | Accepted | 68ms | 21240 KiB | ||||
37 | Wrong answer | 112ms | 21784 KiB |