結果

問題 No.2667 Constrained Permutation
ユーザー ゼットゼット
提出日時 2024-03-08 22:35:14
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 856 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 848,828 KB
最終ジャッジ日時 2024-03-08 22:35:27
合計ジャッジ時間 12,664 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 40 ms
53,460 KB
testcase_02 AC 127 ms
76,940 KB
testcase_03 AC 113 ms
76,152 KB
testcase_04 AC 144 ms
77,392 KB
testcase_05 AC 118 ms
76,712 KB
testcase_06 AC 149 ms
77,632 KB
testcase_07 AC 49 ms
55,588 KB
testcase_08 AC 106 ms
76,588 KB
testcase_09 AC 107 ms
76,592 KB
testcase_10 AC 56 ms
59,692 KB
testcase_11 AC 104 ms
76,600 KB
testcase_12 AC 152 ms
88,056 KB
testcase_13 AC 69 ms
70,776 KB
testcase_14 AC 293 ms
114,156 KB
testcase_15 AC 393 ms
116,584 KB
testcase_16 AC 390 ms
103,932 KB
testcase_17 AC 192 ms
84,216 KB
testcase_18 AC 297 ms
114,788 KB
testcase_19 AC 298 ms
114,536 KB
testcase_20 AC 326 ms
115,304 KB
testcase_21 AC 513 ms
132,200 KB
testcase_22 AC 535 ms
132,072 KB
testcase_23 AC 543 ms
132,068 KB
testcase_24 AC 161 ms
90,572 KB
testcase_25 AC 252 ms
103,612 KB
testcase_26 AC 299 ms
114,940 KB
testcase_27 AC 306 ms
114,852 KB
testcase_28 AC 247 ms
105,604 KB
testcase_29 AC 226 ms
99,716 KB
testcase_30 AC 251 ms
103,420 KB
testcase_31 AC 177 ms
94,116 KB
testcase_32 AC 103 ms
77,944 KB
testcase_33 AC 495 ms
130,792 KB
testcase_34 AC 185 ms
94,112 KB
testcase_35 AC 319 ms
106,104 KB
testcase_36 AC 356 ms
104,312 KB
testcase_37 AC 332 ms
110,712 KB
testcase_38 MLE -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
l=0
r=10**10
L=[]
R=[]
h=[]
u=10**10
for i in range(N):
  a,b=map(int,input().split())
  L.append(a-1)
  R.append(b-1)
  h.append([a-1,b-1])
  u=min(u,a-1)
L.sort()
R.sort()
for i in range(N):
  l=max(l,L[i]-i)
for i in range(N):
  r=min(r,R[i]-i)
if l>r:
  print(0)
  exit()
ans=r-l+1
if ans>10**2:
  print(ans)
  exit()
p=0
for i in range(N):
  h[i][0]-=u
  h[i][1]-=u
  p=max(p,h[i][0])
G=[[] for i in range(p+1)]
for i in range(N):
  x,y=h[i][:]
  G[x].append(y)
result=0
from heapq import heappush,heappop
for k in range(l-u,r-u+1):
  S=[]
  b=True
  for x in range(k):
    for y in G[x]:
      heappush(S,y)
  for i in range(N):
    t=i+k
    if t<=p:
      for y in G[t]:
        heappush(S,y)
    if len(S)==0:
      b=False
      break
    w=heappop(S)
    if w<t:
      b=False
      break
  if b==True:
    result+=1
print(result)
0