8000 Merge pull request #29 from tongnamuu/7795 · ChoJH1998/basic-algo-lecture@584f2b2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 584f2b2

Browse files
Merge pull request encrypted-def#29 from tongnamuu/7795
boj 7795
2 parents 415a67b + 4ed8e50 commit 584f2b2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

0x0F/solutions/7795_2.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Authored by : tongnamuu
2+
// Co-authored by : -
3+
// http://boj.kr/c1c7cd2d6487442f83a3fc8f1267c058
4+
// 이분탐색을 이용한 풀이
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
int a[20001];
8+
int main(void){
9+
ios::sync_with_stdio(0);
10+
cin.tie(0);
11+
int T;cin>>T;
12+
while(T--){
13+
int n,m;cin>>n>>m;
14+
for(int i=0;i<n;++i) cin>>a[i];
15+
sort(a, a+n);
16+
int ans = 0;
17+
for(int i=0;i<m;++i){
18+
int num;cin>>num;
19+
int index = upper_bound(a, a+n, num) - a;
20+
ans += n - index;
21+
}
22+
cout<<ans<<'\n';
23+
}
24+
}

0 commit comments

Comments
 (0)
0