-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path20.cpp
36 lines (27 loc) · 795 Bytes
/
20.cpp
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
// O(n*log(n))
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
#define FILE_IO {freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);}
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL)
int main() {
FAST_IO;
// FILE_IO;
int n, tasks[2010], bTasks[2010], ranks[2010] = {0};
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> tasks[i];
bTasks[i] = tasks[i];
}
sort(tasks, tasks + (sizeof(tasks)/sizeof(tasks[0])) / 2010 * n, greater<int>());
for (int i = 0, r = 1; i < n; ++i, ++r) {
if (ranks[tasks[i]] == 0)
ranks[tasks[i]] = r;
}
for (int i = 0; i < n; ++i) {
cout << ranks[bTasks[i]] << " ";
}
return 0;
}