#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#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, same;
ll i, j, rs, N;
cin >> N;
vector<ll> lucky(N);
for(i = 0; i < N; i++)
cin >> lucky[i];
rs = -1;
ok = same = true;
vector<ll> ans(N, 0);
stack<ll> free_places;
for(i = 1; i < N; i++) {
if(lucky[i] == lucky[i - 1])
continue;
same = false;
if(lucky[i] < lucky[i - 1] || ((lucky[i] - lucky[i - 1]) > (i - rs + ((ll) 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(same) {
if(!lucky[0])
fill(all(ans), 1);
else if(lucky[0] > 1)
ok = false;
}
if(ok) {
cout << "IGEN\n";
for(const auto &x : ans)
cout << x << ' ';
cout << '\n';
}
else
cout << "NEM\n";
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2064 KiB | ||||
subtask2 | 2/8 | ||||||
3 | Accepted | 3ms | 2228 KiB | ||||
4 | Partially correct | 3ms | 2440 KiB | ||||
5 | Accepted | 3ms | 2656 KiB | ||||
6 | Partially correct | 3ms | 2740 KiB | ||||
7 | Accepted | 2ms | 2748 KiB | ||||
8 | Accepted | 3ms | 2740 KiB | ||||
9 | Accepted | 3ms | 2868 KiB | ||||
10 | Accepted | 3ms | 3084 KiB | ||||
11 | Accepted | 2ms | 3156 KiB | ||||
subtask3 | 16/16 | ||||||
12 | Accepted | 2ms | 3160 KiB | ||||
13 | Accepted | 3ms | 3164 KiB | ||||
14 | Accepted | 3ms | 3292 KiB | ||||
15 | Accepted | 3ms | 3508 KiB | ||||
16 | Accepted | 3ms | 3724 KiB | ||||
subtask4 | 32/32 | ||||||
17 | Accepted | 4ms | 4052 KiB | ||||
18 | Accepted | 4ms | 4052 KiB | ||||
19 | Accepted | 4ms | 4048 KiB | ||||
20 | Accepted | 4ms | 4200 KiB | ||||
21 | Accepted | 4ms | 4116 KiB | ||||
22 | Accepted | 4ms | 4116 KiB | ||||
23 | Accepted | 4ms | 4124 KiB | ||||
24 | Accepted | 3ms | 4236 KiB | ||||
subtask5 | 44/44 | ||||||
25 | Accepted | 112ms | 19928 KiB | ||||
26 | Accepted | 115ms | 19788 KiB | ||||
27 | Accepted | 112ms | 19832 KiB | ||||
28 | Accepted | 112ms | 19728 KiB | ||||
29 | Accepted | 115ms | 19916 KiB | ||||
30 | Accepted | 115ms | 20100 KiB | ||||
31 | Accepted | 112ms | 20252 KiB | ||||
32 | Accepted | 112ms | 20128 KiB | ||||
33 | Accepted | 114ms | 20252 KiB | ||||
34 | Accepted | 115ms | 20164 KiB | ||||
35 | Accepted | 118ms | 20176 KiB | ||||
36 | Accepted | 71ms | 21192 KiB | ||||
37 | Accepted | 71ms | 21792 KiB |