BOJ - 17393 - 다이나믹 롤러

Updated:

import sys

def upper_bound(xs, target):
	low, high = 0, len(xs) - 1
	while low <= high:
		mid = (low + high) // 2
		if xs[mid] > target:
			high = mid - 1
		else:
			low = mid + 1
	return low

def solution():
    N = int(input())
    A = list(map(int, sys.stdin.readline().split()))
    B = list(map(int, sys.stdin.readline().split()))

    for i in range(N):
        print(upper_bound(B, A[i]) - i - 1, end=' ')

solution()

https://www.acmicpc.net/problem/17393

Categories:

Updated:

Leave a comment