結果
| 問題 | No.2667 Constrained Permutation |
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2026-07-13 01:50:04 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 792 bytes |
| 記録 | |
| コンパイル時間 | 286 ms |
| コンパイル使用メモリ | 96,220 KB |
| 実行使用メモリ | 252,208 KB |
| 最終ジャッジ日時 | 2026-07-13 01:50:22 |
| 合計ジャッジ時間 | 8,969 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 TLE * 1 -- * 31 |
ソースコード
from sys import stdin
input = stdin.readline
from heapq import heappush, heappop
def func(k):
idx = 0
que = []
for i in range(1, N+1):
n = i+k
while idx < N and LR[idx][0] <= n:
heappush(que, LR[idx][1])
idx += 1
if not que: return -1
if que[0] < n: return 1
heappop(que)
return 0
N = int(input())
LR = [list(map(int, input().split())) for _ in range(N)]
LR.sort(key=lambda x:x[0])
left = -1
right = 10**9
while left+1 < right:
mid = (left+right)//2
if func(mid) == -1:
left = mid
else:
right = mid
L = left+1
left = -1
right = 10**9
while left+1 < right:
mid = (left+right)//2
if func(mid) == 1:
right = mid
else:
left = mid
R = right-1
print(R-L+1)
detteiuu