結果
| 問題 | No.3085 Easy  Problems | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-04-04 22:23:13 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 719 bytes | 
| コンパイル時間 | 366 ms | 
| コンパイル使用メモリ | 82,728 KB | 
| 実行使用メモリ | 181,596 KB | 
| 最終ジャッジ日時 | 2025-04-04 22:24:48 | 
| 合計ジャッジ時間 | 11,711 ms | 
| ジャッジサーバーID (参考情報) | judge6 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 3 TLE * 28 | 
ソースコード
from collections import defaultdict
from bisect import bisect_left
N=int(input())
cntA=defaultdict(int)
B=set()
cntAB=defaultdict(int)
for _ in range(N):
    a,b=map(int,input().split())
    cntA[a]+=1
    B.add(b)
    cntAB[(a,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 B:
    cumsumB[b]=[(0,0)]
for (a,b),cnt in sorted(cntAB.items()):
    cumsumB[b].append((a,cumsumB[b][-1][1]+cnt))
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)
            
            
            
        