結果

問題 No.3085 Easy Problems
コンテスト
ユーザー Musaddiq K
提出日時 2025-12-25 20:04:41
言語 PyPy3
(7.3.17)
結果
WA  
実行時間 -
コード長 892 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 303 ms
コンパイル使用メモリ 82,572 KB
実行使用メモリ 119,388 KB
最終ジャッジ日時 2025-12-25 20:05:17
合計ジャッジ時間 34,375 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 1 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict
import bisect

# Read number of problems
N = int(input())

problems = []
for _ in range(N):
    A, B = map(int, input().split())
    problems.append((A, B))

# Read number of people
Q = int(input())

people = []
for _ in range(Q):
    X, Y = map(int, input().split())
    people.append((X, Y))

# Sort problems by difficulty
problems.sort()
difficulties = [p[0] for p in problems]

# Count number of problems in each field
field_count = defaultdict(int)
for _, b in problems:
    field_count[b] += 1

# Calculate easy problems for each person
results = []
for X, Y in people:
    # Number of problems with difficulty <= X
    total_easy = bisect.bisect_right(difficulties, X)
    # Subtract problems in their weak field
    easy_count = total_easy - field_count.get(Y, 0)
    results.append(easy_count)

# Output results
for res in results:
    print(res)
0