64152023-11-28 17:44:36horvathabelTitkos sorozatcpp17Accepted 40/4056ms7504 KiB
#include <bits/stdc++.h>
using namespace std;
bool compa(pair<int,int> a, pair<int,int> b){
	if(a.first!=b.first) return (a.first>b.first);
	return a.second<b.second; 
}
int main() {
	int n;
	cin>>n;
	vector<int> ans;
	ans.resize(n+1,0);
	int mx=n;
	vector<pair<int,int>> v; 
	for (int i=1; i<=n;i++){
		int x;
		cin>>x;
		if (x==-1){
			ans[i]=mx;
			mx--;
		}
		else{
			v.push_back({x,i});
		}
	}
	sort(v.begin(),v.end(), compa);
	for (pair<int,int> x:v){
		ans[x.second]=mx;
		mx--;
	}
	for (int i=1; i<=n;i++) cout<<ans[i]<<" "; 
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1684 KiB
2Accepted0/028ms3504 KiB
3Accepted1/13ms2060 KiB
4Accepted1/13ms2272 KiB
5Accepted2/23ms2484 KiB
6Accepted1/13ms2584 KiB
7Accepted1/13ms2712 KiB
8Accepted2/23ms2920 KiB
9Accepted2/256ms6052 KiB
10Accepted2/256ms6224 KiB
11Accepted2/256ms6432 KiB
12Accepted2/254ms6656 KiB
13Accepted2/254ms6780 KiB
14Accepted2/254ms6864 KiB
15Accepted2/254ms6872 KiB
16Accepted3/354ms6876 KiB
17Accepted3/354ms6908 KiB
18Accepted3/354ms7104 KiB
19Accepted3/354ms7152 KiB
20Accepted3/352ms7056 KiB
21Accepted1/152ms7176 KiB
22Accepted1/150ms7268 KiB
23Accepted1/150ms7504 KiB