73112024-01-06 20:34:02anonMexxcpp17Partially correct 0/100115ms21784 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;
    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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2048 KiB
subtask20/8
3Partially correct3ms2176 KiB
4Partially correct3ms2372 KiB
5Accepted3ms2580 KiB
6Partially correct3ms2820 KiB
7Wrong answer3ms3160 KiB
8Accepted3ms3156 KiB
9Accepted3ms3256 KiB
10Accepted3ms3240 KiB
11Wrong answer3ms3396 KiB
subtask30/16
12Accepted3ms3488 KiB
13Accepted2ms3480 KiB
14Accepted3ms3484 KiB
15Accepted3ms3488 KiB
16Wrong answer3ms3492 KiB
subtask40/32
17Accepted4ms3736 KiB
18Accepted4ms3768 KiB
19Accepted4ms3764 KiB
20Accepted4ms3956 KiB
21Accepted4ms4044 KiB
22Accepted4ms4044 KiB
23Accepted3ms4052 KiB
24Wrong answer4ms4312 KiB
subtask50/44
25Accepted114ms20248 KiB
26Accepted114ms19916 KiB
27Accepted112ms19844 KiB
28Accepted112ms20072 KiB
29Accepted114ms20212 KiB
30Accepted114ms20244 KiB
31Accepted114ms20320 KiB
32Accepted112ms20344 KiB
33Accepted112ms20264 KiB
34Accepted112ms20216 KiB
35Accepted115ms20308 KiB
36Accepted68ms21240 KiB
37Wrong answer112ms21784 KiB