23662023-01-11 14:17:25rennTitkos sorozatcpp11Accepted 40/4021ms5656 KiB
#include <bits/stdc++.h>
using namespace std;

vector<bool> volt;

int main() {
        cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> sor(n);
	for (int i = 0; i < n; i++) {
		cin >> sor[i];
	}
	int legk = 1;
	int legn = n;
	volt.resize(n);
	vector<int> mo(n);
	for (int i = 0; i < n; i++) {
		if (sor[i] == -1) {
			mo[i] = legn;
			legn--;
		} else {
			mo[i] = legk + sor[i] - i - 2;
			volt[mo[i]] = 1;
			if (mo[i] == legk) {
				legk++;
				while (volt[legk] == 1) {
					legk++;
				}
			}
		}
		cout << mo[i] << " ";
	}
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1824 KiB
2Accepted0/012ms2844 KiB
3Accepted1/12ms2228 KiB
4Accepted1/12ms2444 KiB
5Accepted2/22ms2524 KiB
6Accepted1/12ms2748 KiB
7Accepted1/12ms2948 KiB
8Accepted2/22ms3156 KiB
9Accepted2/221ms4524 KiB
10Accepted2/221ms4536 KiB
11Accepted2/221ms4740 KiB
12Accepted2/221ms4984 KiB
13Accepted2/221ms5056 KiB
14Accepted2/221ms5212 KiB
15Accepted2/221ms5348 KiB
16Accepted3/321ms5448 KiB
17Accepted3/321ms5444 KiB
18Accepted3/321ms5452 KiB
19Accepted3/321ms5564 KiB
20Accepted3/320ms5472 KiB
21Accepted1/121ms5508 KiB
22Accepted1/121ms5504 KiB
23Accepted1/121ms5656 KiB