結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 47 ms
60,992 KB
testcase_03 AC 72 ms
63,356 KB
testcase_04 AC 69 ms
70,916 KB
testcase_05 AC 45 ms
61,048 KB
testcase_06 AC 70 ms
70,916 KB
testcase_07 AC 45 ms
61,048 KB
testcase_08 AC 71 ms
72,984 KB
testcase_09 AC 70 ms
72,988 KB
testcase_10 AC 53 ms
63,096 KB
testcase_11 AC 70 ms
70,924 KB
testcase_12 AC 304 ms
81,380 KB
testcase_13 AC 73 ms
72,984 KB
testcase_14 AC 879 ms
108,956 KB
testcase_15 AC 422 ms
91,712 KB
testcase_16 AC 339 ms
89,260 KB
testcase_17 AC 140 ms
79,204 KB
testcase_18 AC 858 ms
97,308 KB
testcase_19 AC 823 ms
95,660 KB
testcase_20 AC 891 ms
97,180 KB
testcase_21 AC 537 ms
97,068 KB
testcase_22 AC 540 ms
96,272 KB
testcase_23 AC 543 ms
96,688 KB
testcase_24 AC 378 ms
83,892 KB
testcase_25 AC 768 ms
98,748 KB
testcase_26 AC 867 ms
97,704 KB
testcase_27 AC 894 ms
98,228 KB
testcase_28 AC 449 ms
95,916 KB
testcase_29 AC 418 ms
92,360 KB
testcase_30 AC 503 ms
103,600 KB
testcase_31 AC 295 ms
84,528 KB
testcase_32 AC 112 ms
77,540 KB
testcase_33 WA -
testcase_34 AC 318 ms
84,520 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 466 ms
88,572 KB
testcase_39 AC 71 ms
72,984 KB
testcase_40 AC 318 ms
84,520 KB
testcase_41 AC 527 ms
95,728 KB
testcase_42 AC 415 ms
86,184 KB
testcase_43 AC 588 ms
104,876 KB
testcase_44 AC 273 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**20;rr=10**20
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**20;rr=10**20
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