22812023-01-09 12:28:49rennTitkos sorozatcpp11Accepted 40/4028ms6460 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()
{
    cin.tie(0);
    iostream::sync_with_stdio(0);
    int n;
    cin >> n;
    
    vector<pii> A;
    vector<int> B;
    int x;
    
    for(int i = 0; i < n; i++){
        cin >> x;
        if(x == -1){
            B.push_back(i);
        }
        else{
            A.push_back({x, i});
        }
    }
    sort(A.begin(), A.end(), comp());
    sort(B.begin(), B.end(), greater<int>());
    
    vector<int> mo(n);
    int akt = 1;
    for(pii x : A){
        mo[x.second] = akt++;
    }
    for(int x : B){
        mo[x] = akt++;
    }
    
    for(int x : mo){
        cout << x << " ";
    }
    cout << "\n";

    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1824 KiB
2Accepted0/014ms3224 KiB
3Accepted1/12ms2488 KiB
4Accepted1/12ms2448 KiB
5Accepted2/22ms2648 KiB
6Accepted1/12ms2908 KiB
7Accepted1/12ms3240 KiB
8Accepted2/22ms3316 KiB
9Accepted2/228ms5772 KiB
10Accepted2/227ms5976 KiB
11Accepted2/227ms5976 KiB
12Accepted2/226ms5976 KiB
13Accepted2/226ms6204 KiB
14Accepted2/226ms6196 KiB
15Accepted2/226ms6176 KiB
16Accepted3/326ms6188 KiB
17Accepted3/326ms6184 KiB
18Accepted3/326ms6192 KiB
19Accepted3/326ms6320 KiB
20Accepted3/325ms6440 KiB
21Accepted1/126ms6384 KiB
22Accepted1/125ms6460 KiB
23Accepted1/125ms6456 KiB