23892023-01-12 13:02:11sztomiTitkos sorozatcpp11Accepted 40/4029ms6784 KiB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

struct comp{
    bool operator()(pii a, pii b){
        if(a.first == b.first) return a.second > b.second;
        return a.first < b.first;
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> neg;
    vector<pii> tobbi;
    int a;
    for(int i = 1; i <= n; i++){
        cin >> a;
        if(a == -1){
            neg.push_back(i);
        }
        else{
            tobbi.push_back({a, i});
        }
    }
    sort(neg.begin(), neg.end(), greater<int>());
    sort(tobbi.begin(), tobbi.end(), comp());
    vector<int> megoldas(n+1, -1);
    int akt = 1;
    for(auto x : tobbi){
        megoldas[x.second] = akt++;
    }
    for(int x : neg){
        megoldas[x] = akt++;
    }
    for(int i = 1; i <= n; i++){
        cout << megoldas[i] << " ";
    }
    cout << "\n";
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1832 KiB
2Accepted0/014ms3264 KiB
3Accepted1/12ms2512 KiB
4Accepted1/12ms2596 KiB
5Accepted2/22ms2736 KiB
6Accepted1/12ms2976 KiB
7Accepted1/12ms3316 KiB
8Accepted2/22ms3396 KiB
9Accepted2/229ms6028 KiB
10Accepted2/228ms5812 KiB
11Accepted2/228ms5872 KiB
12Accepted2/228ms6016 KiB
13Accepted2/228ms6032 KiB
14Accepted2/227ms6080 KiB
15Accepted2/227ms6172 KiB
16Accepted3/327ms6304 KiB
17Accepted3/327ms6512 KiB
18Accepted3/327ms6672 KiB
19Accepted3/327ms6684 KiB
20Accepted3/326ms6684 KiB
21Accepted1/126ms6756 KiB
22Accepted1/126ms6724 KiB
23Accepted1/126ms6784 KiB