結果

問題 No.3085 Easy Problems
ユーザー flippergo
提出日時 2025-05-25 13:09:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 920 ms / 2,000 ms
コード長 520 bytes
コンパイル時間 2,031 ms
コンパイル使用メモリ 81,568 KB
実行使用メモリ 145,328 KB
最終ジャッジ日時 2025-05-25 13:10:17
合計ジャッジ時間 32,754 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_right
N= int(input())
A = [list(map(int,input().split())) for _ in range(N)]
Q = int(input())
X = [list(map(int,input().split())) for _ in range(Q)]
B = {}
for i in range(N):
    a,b = A[i]
    if b not in B:
        B[b] = []
    B[b].append(a)
for b in B:
    B[b] = sorted(B[b])
A = sorted([A[i][0] for i in range(N)])
for k in range(Q):
    x,y = X[k]
    indx = bisect_right(A,x)
    if y not in B:
        print(indx)
    else:
        indy = bisect_right(B[y],x)
        print(indx-indy)
0