Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
Tags
- ์ด์งํ์
- ์ ์ ์ค๋ ๋
- ๋น๋ํจํด
- github
- Greedy
- ๋ฐฑ์ค
- Stack
- ์ ์๋ก
- ๋ถํ ์ ๋ณต
- ํ๋ก์ธ์ค
- ๋ฐฐ์ด ๋๋ฆฌ๊ธฐ1
- ๊ทธ๋ํํ์
- ๋งํฌ๋ค์ด
- ํ๊ณ
- Markdown
- Python
- GarbageCollector
- DP
- deque
- springboot
- ๋ธ๋ฃจํธํฌ์ค
- ๋ฌธ์ ํ์ด
- ๊ทธ๋ํ ํ์
- g1gc
- ๋ฉด์ ๋ณต๊ธฐ
- ๊ตฌํ
- BFS
- ๊ทธ๋ฆฌ๋
- ๋ชฌํฐํ
- GC
Archives
- Today
- Total
FeelingXD
[๋ฐฑ์ค-7795] ๋จน์๊ฒ์ธ๊ฐ ๋จนํ๊ฒ์ธ๊ฐ ๋ณธ๋ฌธ
โ Problem
๐ค How
- A ๋ฆฌ์คํธ์ ์์๋ง๋ค ์ด์งํ์์ ์งํํด์ ํผํฌ์ธ๋ฑ์ค๋ฅผ ์ฐพ์ B์ ๊ธธ์ด-ํผํฌ์ธ๋ฑ์ค(A๋ฆฌ์คํธ ์์ ๋ณด๋ค์์ ์ต๋ ์ธ๋ฑ์ค) ๋ฅผ ๊ฐ์ ํฉ์ฐํด์ฃผ๋ ๋ฐฉ์์ผ๋ก ์ ๊ทผํ์๋ค.
โ Solve
# ๋จน์ ๊ฒ์ธ๊ฐ ๋จนํ ๊ฒ์ธ๊ฐ
import sys
input =sys.stdin.readline
def action():
len_A,len_B=map(int,input().split())
list_A=list(map(int,input().split())) # A ๋ฆฌ์คํธ
list_B=sorted(list(map(int,input().split()))) # B ๋ฆฌ์คํธ
ans=0
for v in list_A:
l=0
r=len_B-1
m_i=-1 # ๊ธฐ๋ณธ๊ฐ ์ด๊ธฐํ
while l<=r and v>list_B[0]: # 2์ง ํ์
mid=(l+r)//2
if v>list_B[mid]:
m_i=mid
l=mid+1
else:
r=mid-1
ans+= m_i+1
print(ans)
pass
def solution():
for _ in range(int(input())):
action()
pass
if __name__=="__main__": # ์คํ๋๋ ๋ถ๋ถ
solution()
pass