Official

B - 品質検査と製品の廃棄 / Quality Inspection and Product Disposal Editorial by sounansya


\(A\) をソートし、まだ廃棄されていない製品があと何個かを持ちます。各クエリではまだ廃棄されていない製品のうち品質スコアが最小のものを見て、その商品を廃棄するかを順番に見ていきます。

実装例(Python3)

n, que = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
now = 0
for _ in range(que):
    t = int(input())
    ans = 0
    while now != n and a[now] < t:
        now += 1
        ans += 1
    print(ans)

posted:
last update: