-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCodeForces 978F - Mentors.cpp
52 lines (41 loc) · 1.17 KB
/
CodeForces 978F - Mentors.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")
using namespace std;
#define inc(a) a.begin(), a.end()
#define dec(a) a.rbegin(), a.rend()
#define Unique(a) a.erase(unique(inc(a)), a.end())
#define what_is(x) cerr << #x << " is " << x << '\n';
using ll = long long;
using ld = long double;
int dx[] = {1, -1, 0, 1, -1, 0, 1, -1, 0};
int dy[] = {0, 0, 0, -1, -1, -1, 1, 1, 1};
const int N = 2E5+5, M = 1E6+5, MOD = 1E9+7;
int n, k, a[N], b[N], l, r, mid, ans;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for(int i=0; i<n; ++i)
cin >> a[i], b[i] = a[i];
sort(b, b+n);
map<pair<int, int>, int> mp;
for(int i=0; i<n; ++i){
l = ans = 0, r = n-1;
while (l <= r){
mid = (l+r)/2;
if(b[mid] < a[i])
ans = l = mid+1;
else r = mid-1;
}
mp[{a[i], i}] = ans;
}
while (k--){
cin >> l >> r;
l--, r--;
if(a[l] > a[r]) mp[{a[l], l}]--;
else if(a[r] > a[l]) mp[{a[r], r}]--;
}
for(int i=0; i<n; ++i)
cout << mp[{a[i], i}] << " \n"[i == n-1];
return 0;
}