結果
問題 |
No.3085 Easy Problems
|
ユーザー |
|
提出日時 | 2025-04-04 22:10:23 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 752 bytes |
コンパイル時間 | 420 ms |
コンパイル使用メモリ | 82,384 KB |
実行使用メモリ | 175,272 KB |
最終ジャッジ日時 | 2025-04-04 22:11:54 |
合計ジャッジ時間 | 73,606 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 4 TLE * 27 |
ソースコード
from collections import defaultdict from bisect import bisect_left N=int(input()) A=[] B=[] AB=[] cntA=defaultdict(int) cntB=defaultdict(int) for _ in range(N): a,b=map(int,input().split()) A.append(a) B.append(b) AB.append((a,b)) cntA[a]+=1 cntB[b]+=1 cumsumA=[(0,0)] for a,cnt in sorted(cntA.items()): cumsumA.append((a,cumsumA[-1][1]+cnt)) cumsumB=defaultdict(list) for b in cntB.keys(): cumsumB[b]=[(0,0)] for a,b in sorted(AB): cumsumB[b].append((a,cumsumB[b][-1][1]+1)) Q=int(input()) for _ in range(Q): x,y=map(int,input().split()) idxA=bisect_left(cumsumA,(x,10**9)) idxB=bisect_left(cumsumB[y],(x,10**9)) ans=cumsumA[idxA-1][1] ans-=cumsumB[y][idxB-1][1] if idxB>0 else 0 print(ans)