-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1041C.cpp
More file actions
57 lines (30 loc) · 808 Bytes
/
1041C.cpp
File metadata and controls
57 lines (30 loc) · 808 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,m,d;
cin >> n >> m >> d;
set < pair <int,int> > conj;
int arr[n];
for(int i=0;i<n;i++){
cin >> arr[i];
conj.insert( make_pair(arr[i],i) );
}
int saida[n];
int dia = 1;
while(!conj.empty()){
set < pair <int,int> >::iterator it = conj.begin();
while(it != conj.end()){
saida[it->second] = dia;
int x = it->first;
conj.erase(it);
it = conj.lower_bound(make_pair(x+d+1,0));
}
dia++;
}
cout << dia-1 << endl;
for(int i=0;i<n;i++){
cout << saida[i] << " ";
}
cout << endl;
return 0;
}