File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include < iostream>
2+ #include < set>
3+ #include < vector>
4+
5+ using namespace std ;
6+
7+ int N;
8+ vector<int > rs, ko;
9+
10+ int func (vector<int >& rs, vector<int >& ko){
11+ int result = 0 ;
12+
13+ // 이진 검색 트리인 multiset을 사용
14+ multiset<int > ratings (ko.begin (),ko.end ());
15+ for (int rus = 0 ; rus < N; rus++){
16+ // 가장 레이팅이 높은 선수가 이길 수 없는경우 가장 낮은 것을제시
17+ if (*ratings.rbegin () < rs[rus]){
18+ ratings.erase (ratings.begin ());
19+ }else {
20+ // 이길 수 있는 경우 lower_bound를 통해 가장 작은 값을 제시
21+ ratings.erase (ratings.lower_bound (rs[rus]));
22+ result++;
23+ }
24+ }
25+
26+ return result;
27+ }
28+
29+ int main (void ){
30+ ios::sync_with_stdio (0 );
31+ cin.tie (0 );
32+
33+ int cc;
34+ cin >> cc;
35+ for (int c=0 ; c < cc; c++){
36+ cin >> N;
37+ rs.clear ();
38+ ko.clear ();
39+
40+ for (int i=0 ; i < N; i++){
41+ int tmp;
42+ cin >> tmp;
43+ rs.push_back (tmp);
44+ }
45+
46+ for (int i=0 ; i < N; i++){
47+ int tmp;
48+ cin >> tmp;
49+ ko.push_back (tmp);
50+ }
51+
52+ cout << func (rs,ko) << endl;
53+ }
54+
55+ return 0 ;
56+ }
You can’t perform that action at this time.
0 commit comments