結果

問題 No.2248 max(C)-min(C)
ユーザー 👑 timitimi
提出日時 2023-03-20 12:04:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,435 ms / 3,000 ms
コード長 1,028 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 308,176 KB
最終ジャッジ日時 2023-10-18 18:03:29
合計ジャッジ時間 28,508 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,392 KB
testcase_01 AC 39 ms
53,392 KB
testcase_02 AC 40 ms
53,392 KB
testcase_03 AC 69 ms
63,700 KB
testcase_04 AC 48 ms
61,652 KB
testcase_05 AC 43 ms
55,440 KB
testcase_06 AC 64 ms
70,548 KB
testcase_07 AC 68 ms
72,616 KB
testcase_08 AC 69 ms
72,616 KB
testcase_09 AC 73 ms
73,836 KB
testcase_10 AC 42 ms
55,440 KB
testcase_11 AC 67 ms
72,608 KB
testcase_12 AC 53 ms
63,728 KB
testcase_13 AC 61 ms
68,472 KB
testcase_14 AC 67 ms
72,608 KB
testcase_15 AC 69 ms
72,636 KB
testcase_16 AC 51 ms
63,712 KB
testcase_17 AC 71 ms
72,768 KB
testcase_18 AC 728 ms
261,648 KB
testcase_19 AC 205 ms
101,208 KB
testcase_20 AC 793 ms
305,920 KB
testcase_21 AC 857 ms
283,300 KB
testcase_22 AC 526 ms
248,780 KB
testcase_23 AC 350 ms
177,272 KB
testcase_24 AC 182 ms
118,256 KB
testcase_25 AC 718 ms
270,588 KB
testcase_26 AC 640 ms
257,512 KB
testcase_27 AC 710 ms
270,692 KB
testcase_28 AC 127 ms
102,324 KB
testcase_29 AC 654 ms
260,068 KB
testcase_30 AC 288 ms
150,364 KB
testcase_31 AC 799 ms
305,968 KB
testcase_32 AC 196 ms
114,532 KB
testcase_33 AC 275 ms
149,416 KB
testcase_34 AC 774 ms
300,776 KB
testcase_35 AC 786 ms
306,032 KB
testcase_36 AC 795 ms
308,176 KB
testcase_37 AC 414 ms
206,592 KB
testcase_38 AC 758 ms
265,740 KB
testcase_39 AC 771 ms
265,420 KB
testcase_40 AC 742 ms
265,172 KB
testcase_41 AC 667 ms
259,292 KB
testcase_42 AC 763 ms
265,692 KB
testcase_43 AC 697 ms
260,736 KB
testcase_44 AC 760 ms
265,860 KB
testcase_45 AC 628 ms
260,348 KB
testcase_46 AC 362 ms
164,944 KB
testcase_47 AC 764 ms
262,640 KB
testcase_48 AC 463 ms
184,824 KB
testcase_49 AC 1,413 ms
305,620 KB
testcase_50 AC 1,403 ms
306,444 KB
testcase_51 AC 1,405 ms
307,932 KB
testcase_52 AC 1,435 ms
306,476 KB
testcase_53 AC 293 ms
118,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
  from sys import stdin, setrecursionlimit
  input = stdin.readline
  readline = stdin.readline

  N=int(input())
  A=list(map(int, input().split()))
  B=list(map(int, input().split()))
  if N==1:
    print(0)
    exit()

  import sys
  input = sys.stdin.readline
  D={}
  E=[]
  import heapq
  Q=[]
  for i in range(N):
    a,b,c=A[i],B[i],(A[i]+B[i])//2
    E.append(a)
    E.append(b)
    E.append(c)
    if a!=b:
      a,b,c=sorted([a,b,c])[::-1]
      heapq.heappush(Q,a) 
      if a not in D:
        D[a]=[]
      D[a].append(b)
      if b not in D:
        D[b]=[]
      D[b].append(c)
      if c not in D:
        D[c]=[]
      D[c].append(-1)
    else:
      heapq.heappush(Q,a) 
      if a not in D:
        D[a]=[]
      D[a].append(-1)
  #print(Q,D)
  E=sorted(list(set(E)))[::-1]
  #print(E)
  ans=10**12
  for e in E:
    mi=heapq.heappop(Q)
    ans=min(ans,e-mi)
    heapq.heappush(Q,mi)
    for nex in D[e]:
      if nex==-1:
        print(ans)
        exit()
      heapq.heappush(Q,nex)
    
main()
0