結果

問題 No.2667 Constrained Permutation
ユーザー 👑 timitimi
提出日時 2024-03-08 23:09:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 108,956 KB
最終ジャッジ日時 2024-03-08 23:10:08
合計ジャッジ時間 18,998 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 53 ms
60,992 KB
testcase_03 AC 54 ms
63,356 KB
testcase_04 AC 69 ms
70,916 KB
testcase_05 AC 45 ms
61,048 KB
testcase_06 AC 69 ms
70,924 KB
testcase_07 AC 46 ms
61,048 KB
testcase_08 AC 71 ms
72,984 KB
testcase_09 AC 71 ms
72,984 KB
testcase_10 AC 54 ms
63,096 KB
testcase_11 AC 69 ms
70,924 KB
testcase_12 AC 303 ms
81,380 KB
testcase_13 AC 74 ms
72,984 KB
testcase_14 AC 886 ms
108,956 KB
testcase_15 AC 426 ms
91,732 KB
testcase_16 AC 322 ms
89,260 KB
testcase_17 AC 142 ms
79,204 KB
testcase_18 AC 897 ms
97,184 KB
testcase_19 AC 787 ms
95,616 KB
testcase_20 AC 895 ms
97,184 KB
testcase_21 AC 540 ms
97,092 KB
testcase_22 AC 545 ms
96,372 KB
testcase_23 AC 537 ms
96,704 KB
testcase_24 AC 406 ms
83,896 KB
testcase_25 AC 746 ms
98,744 KB
testcase_26 AC 884 ms
97,832 KB
testcase_27 AC 887 ms
98,232 KB
testcase_28 AC 455 ms
95,936 KB
testcase_29 AC 419 ms
92,372 KB
testcase_30 AC 501 ms
103,596 KB
testcase_31 AC 297 ms
84,524 KB
testcase_32 AC 114 ms
77,540 KB
testcase_33 WA -
testcase_34 AC 294 ms
84,520 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 446 ms
88,572 KB
testcase_39 AC 72 ms
72,984 KB
testcase_40 AC 321 ms
84,524 KB
testcase_41 AC 527 ms
95,724 KB
testcase_42 AC 422 ms
86,188 KB
testcase_43 AC 588 ms
104,872 KB
testcase_44 AC 271 ms
81,380 KB
testcase_45 AC 73 ms
72,984 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)
if max(p,q)>min(r,s):
  print(0)
else:
  print(max(0,max(q,s)-min(r,p)+1))
  
0