-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path18870.cpp
More file actions
37 lines (32 loc) · 794 Bytes
/
18870.cpp
File metadata and controls
37 lines (32 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#define io ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
bool compare(pair<int,int> a,pair<int,int> b){
return a.second<b.second;
}
int main()
{
io;
int N;
cin>>N;
vector<pair<int,int>> arr(N);
vector<pair<int,int>> dp(N);
for(int i=0;i<N;i++){
arr[i].first=i;
cin>>arr[i].second;
}
sort(arr.begin(),arr.end(),compare);
dp[0].first=arr[0].first;
dp[0].second=0;
for(int i=1;i<N;i++){
dp[i].first=arr[i].first;
dp[i].second=dp[i-1].second+1;
if(arr[i-1].second==arr[i].second) dp[i].second=dp[i-1].second;
}
sort(dp.begin(),dp.end());
for(int i=0;i<N;i++) cout<<dp[i].second<<' ';
return 0;
}