結果

問題 No.2667 Constrained Permutation
ユーザー ShirotsumeShirotsume
提出日時 2023-12-30 01:13:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 703 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 121,824 KB
最終ジャッジ日時 2024-01-15 12:26:31
合計ジャッジ時間 30,151 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
56,140 KB
testcase_01 AC 42 ms
56,140 KB
testcase_02 AC 47 ms
58,200 KB
testcase_03 AC 54 ms
66,288 KB
testcase_04 AC 63 ms
71,288 KB
testcase_05 AC 46 ms
58,200 KB
testcase_06 AC 63 ms
71,288 KB
testcase_07 AC 46 ms
58,200 KB
testcase_08 AC 66 ms
73,336 KB
testcase_09 AC 66 ms
73,348 KB
testcase_10 AC 54 ms
66,288 KB
testcase_11 AC 63 ms
71,288 KB
testcase_12 AC 414 ms
88,664 KB
testcase_13 AC 73 ms
77,268 KB
testcase_14 AC 1,181 ms
114,912 KB
testcase_15 AC 940 ms
100,656 KB
testcase_16 AC 655 ms
98,916 KB
testcase_17 AC 227 ms
81,188 KB
testcase_18 AC 1,288 ms
121,312 KB
testcase_19 AC 1,271 ms
121,820 KB
testcase_20 AC 1,287 ms
121,568 KB
testcase_21 AC 1,221 ms
104,544 KB
testcase_22 AC 1,247 ms
121,824 KB
testcase_23 AC 1,244 ms
121,440 KB
testcase_24 AC 537 ms
90,444 KB
testcase_25 AC 1,015 ms
98,032 KB
testcase_26 AC 1,278 ms
121,456 KB
testcase_27 AC 1,276 ms
121,368 KB
testcase_28 AC 896 ms
102,972 KB
testcase_29 AC 845 ms
94,268 KB
testcase_30 AC 952 ms
97,216 KB
testcase_31 AC 580 ms
88,792 KB
testcase_32 AC 158 ms
79,140 KB
testcase_33 WA -
testcase_34 AC 637 ms
91,752 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 908 ms
106,672 KB
testcase_39 AC 70 ms
74,836 KB
testcase_40 AC 635 ms
95,204 KB
testcase_41 AC 1,032 ms
111,024 KB
testcase_42 AC 603 ms
100,072 KB
testcase_43 AC 857 ms
111,024 KB
testcase_44 AC 364 ms
85,156 KB
testcase_45 AC 77 ms
77,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353

n = ii()

LR = []

for i in range(n):
    l, r = mi()
    LR.append((l, 1))
    LR.append((r, -1))
LR.sort()

LR2 = [[0, 0] for _ in range(n)]
lcnt = 0
rcnt = 0
for v, x in LR:
    if x == 1:
        LR2[lcnt][0] = v
        lcnt += 1
    else:
        LR2[rcnt][1] = v
        rcnt += 1
    
mink = -inf
maxk = inf
LR = LR2[::]
for i in range(n):
    l, r = LR[i]
    mink = max(mink, l - i)
    maxk = min(maxk, r - i)
print(max(0, maxk - mink + 1))
    
0