結果
問題 |
No.3085 Easy Problems
|
ユーザー |
![]() |
提出日時 | 2025-04-04 21:30:17 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,530 bytes |
コンパイル時間 | 268 ms |
コンパイル使用メモリ | 82,768 KB |
実行使用メモリ | 144,508 KB |
最終ジャッジ日時 | 2025-04-04 21:32:17 |
合計ジャッジ時間 | 5,695 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | TLE * 1 -- * 30 |
ソースコード
class nibutan: @staticmethod def nibutan(ok, ng, op): while abs(ok - ng) > 1: mid = (ok + ng) // 2 if op(mid): ok = mid else: ng = mid return ok @staticmethod def lt(L, n): """Lのうちn未満の最大の要素""" if L[0] >= n: return -1 def op(mid): return L[mid] < n ok = 0 ng = len(L) return nibutan.nibutan(ok, ng, op) @staticmethod def le(L, n): """Lのうちn以下の最大の要素""" if L[0] > n: return -1 def op(mid): return L[mid] <= n ok = 0 ng = len(L) return nibutan.nibutan(ok, ng, op) @staticmethod def gt(L, n): """Lのうちn超過の最小の要素""" if L[-1] <= n: return len(L) def op(mid): return L[mid] > n ok = len(L) - 1 ng = -1 return nibutan.nibutan(ok, ng, op) @staticmethod def ge(L, n): """Lのうちn以上の最小の要素""" if L[-1] < n: return len(L) def op(mid): return L[mid] >= n ok = len(L) - 1 ng = -1 return nibutan.nibutan(ok, ng, op) N = int(input()) AB = [list(map(int, input().split())) for _ in range(N)] Q = int(input()) XY = [list(map(int, input().split())) for _ in range(Q)] A = [AB[i][0] for i in range(N)] A.sort() M = 10 ** 5 + 1 AL = [[] for _ in range(M)] for a, b in AB: AL[b].append(a) for i in range(M): AL[b].sort() for x, y in XY: a = nibutan.le(A, x) + 1 if len(AL[y]) > 0: b = nibutan.le(AL[y], x) + 1 else: b = 0 ans = a - b print(ans)