-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path221.cpp
50 lines (46 loc) · 1010 Bytes
/
221.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
/*************************************************************************
> File Name: 221.cpp
> Author: ws
> Mail: ws1519704327@126.com
> Created Time: 2020年01月09日 星期四 10时38分43秒
************************************************************************/
#include<iostream>
#include <algorithm>
using namespace std;
struct student {
int num, h, ans;
};
bool cmp1(student a, student b) {
return a.h < b.h;
}
bool cmp2(student a, student b) {
return a.num < b.num;
}
int main() {
int n, m;
cin >> n >> m;
student stu[100005];
int hei[100005];
for (int i = 0; i < n; i++) {
cin >> stu[i].h;
stu[i].num = i;
stu[i].ans = 0;
}
for (int i = 0; i < m; i++) {
cin >> hei[i];
}
sort(hei, hei + m);
sort(stu, stu + n, cmp1);
int index = 0;
for (int i = 0; i < n; i++) {
while (stu[i].h >= hei[index] && index < m) {
stu[i].ans++;
index++;
}
}
sort(stu, stu + n, cmp2);
for (int i = 0; i < n; i++) {
cout << stu[i].ans << endl;
}
return 0;
}