結果

問題 No.2667 Constrained Permutation
ユーザー 👑 timitimi
提出日時 2024-03-08 22:35:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 496 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 104,880 KB
最終ジャッジ日時 2024-03-08 22:35:34
合計ジャッジ時間 18,734 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 45 ms
60,992 KB
testcase_03 AC 52 ms
63,360 KB
testcase_04 AC 65 ms
70,924 KB
testcase_05 AC 44 ms
61,048 KB
testcase_06 AC 67 ms
70,928 KB
testcase_07 AC 42 ms
61,060 KB
testcase_08 AC 66 ms
72,984 KB
testcase_09 AC 65 ms
73,000 KB
testcase_10 AC 49 ms
63,096 KB
testcase_11 AC 63 ms
70,928 KB
testcase_12 AC 315 ms
81,508 KB
testcase_13 AC 70 ms
72,980 KB
testcase_14 AC 801 ms
100,128 KB
testcase_15 AC 433 ms
91,804 KB
testcase_16 AC 302 ms
89,392 KB
testcase_17 AC 134 ms
79,204 KB
testcase_18 AC 865 ms
97,316 KB
testcase_19 AC 781 ms
95,788 KB
testcase_20 AC 884 ms
97,316 KB
testcase_21 AC 540 ms
97,188 KB
testcase_22 AC 542 ms
96,468 KB
testcase_23 AC 547 ms
96,800 KB
testcase_24 AC 386 ms
83,896 KB
testcase_25 AC 785 ms
98,748 KB
testcase_26 AC 875 ms
97,832 KB
testcase_27 AC 895 ms
98,360 KB
testcase_28 AC 453 ms
95,984 KB
testcase_29 AC 427 ms
92,472 KB
testcase_30 AC 502 ms
103,728 KB
testcase_31 AC 301 ms
84,528 KB
testcase_32 AC 112 ms
77,540 KB
testcase_33 WA -
testcase_34 AC 293 ms
84,528 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 439 ms
88,592 KB
testcase_39 AC 71 ms
72,984 KB
testcase_40 AC 319 ms
84,528 KB
testcase_41 AC 553 ms
95,856 KB
testcase_42 AC 391 ms
86,188 KB
testcase_43 AC 589 ms
104,880 KB
testcase_44 AC 269 ms
81,508 KB
testcase_45 AC 74 ms
72,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=[];c=10**10
for i in range(N):
  l,r=map(int, input().split())
  A.append((l,r))
  
A=sorted(A,key=lambda x: x[1])
A=sorted(A,key=lambda x: x[0])
#print(A)
B=[]
ll=-10**10;rr=10**10
for i in range(N):
  l,r=A[i]
  ll=max(ll,l-i)
  rr=min(rr,r-i)
p,q=ll,rr#
#print(ll,rr)
  
A=sorted(A,key=lambda x: x[0])
A=sorted(A,key=lambda x: x[1])
#print(A)
ll=-10**10;rr=10**10
for i in range(N):
  l,r=A[i]
  ll=max(ll,l-i)
  rr=min(rr,r-i)
r,s=ll,rr
#print(p,q,r,s)
print(max(0,s-p+1))
  
0