結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 49 ms
60,992 KB
testcase_03 AC 56 ms
63,360 KB
testcase_04 AC 72 ms
70,924 KB
testcase_05 AC 45 ms
61,048 KB
testcase_06 AC 68 ms
70,920 KB
testcase_07 AC 45 ms
61,052 KB
testcase_08 AC 71 ms
72,984 KB
testcase_09 AC 70 ms
72,984 KB
testcase_10 AC 53 ms
63,096 KB
testcase_11 AC 69 ms
70,924 KB
testcase_12 AC 299 ms
81,380 KB
testcase_13 AC 73 ms
72,984 KB
testcase_14 AC 881 ms
108,960 KB
testcase_15 AC 419 ms
91,752 KB
testcase_16 AC 319 ms
89,264 KB
testcase_17 AC 139 ms
79,204 KB
testcase_18 AC 858 ms
97,312 KB
testcase_19 AC 827 ms
95,768 KB
testcase_20 AC 891 ms
97,184 KB
testcase_21 AC 538 ms
97,116 KB
testcase_22 AC 550 ms
96,400 KB
testcase_23 AC 565 ms
96,724 KB
testcase_24 AC 382 ms
83,896 KB
testcase_25 AC 768 ms
98,744 KB
testcase_26 AC 855 ms
97,832 KB
testcase_27 AC 885 ms
98,360 KB
testcase_28 AC 453 ms
95,864 KB
testcase_29 AC 419 ms
92,400 KB
testcase_30 AC 506 ms
103,724 KB
testcase_31 AC 307 ms
84,528 KB
testcase_32 AC 113 ms
77,540 KB
testcase_33 WA -
testcase_34 AC 291 ms
84,524 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 433 ms
88,576 KB
testcase_39 AC 71 ms
72,984 KB
testcase_40 AC 333 ms
84,528 KB
testcase_41 AC 524 ms
95,728 KB
testcase_42 AC 385 ms
86,188 KB
testcase_43 AC 608 ms
104,876 KB
testcase_44 AC 272 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)
d=0
if s<p:
  d=p-s-1
ans=max(0,max(q,s)-min(r,p)+1)
print(max(0,ans-d))
  
0