結果
問題 | No.2248 max(C)-min(C) |
ユーザー | 👑 H20 |
提出日時 | 2023-03-17 22:44:36 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 761 bytes |
コンパイル時間 | 1,151 ms |
コンパイル使用メモリ | 81,648 KB |
実行使用メモリ | 243,308 KB |
最終ジャッジ日時 | 2023-10-18 15:47:28 |
合計ジャッジ時間 | 83,918 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
55,456 KB |
testcase_01 | AC | 43 ms
55,456 KB |
testcase_02 | AC | 42 ms
55,456 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | TLE | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | TLE | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 2,926 ms
225,868 KB |
testcase_43 | WA | - |
testcase_44 | TLE | - |
testcase_45 | AC | 2,338 ms
196,368 KB |
testcase_46 | WA | - |
testcase_47 | AC | 2,979 ms
226,108 KB |
testcase_48 | AC | 1,427 ms
172,364 KB |
testcase_49 | AC | 2,971 ms
240,520 KB |
testcase_50 | AC | 2,950 ms
243,308 KB |
testcase_51 | AC | 2,989 ms
240,248 KB |
testcase_52 | TLE | - |
testcase_53 | AC | 432 ms
99,404 KB |
ソースコード
import heapq import collections N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = [] for i in range(N): if A[i]>B[i]: A[i],B[i]=B[i],A[i] C.append([A[i],(A[i]+B[i])//2,B[i]]) mi = 10**9 ma = 0 h = [] COL = collections.Counter() for i,a in enumerate(A): mi = min(mi,a) ma = max(ma,a) heapq.heappush(h,(a,i,0)) COL[a]+=1 ans = ma-mi while h: before,i,ii= heapq.heappop(h) COL[before]-=1 if ii==0: heapq.heappush(h,((A[i]+B[i])//2,i,1)) ma = max(ma,(A[i]+B[i])//2) COL[(A[i]+B[i])//2]+=1 if ii==1: ma = max(ma,B[i]) COL[B[i]]+=1 if COL[before]==0 and mi==before and len(h): mi=h[0][0] ans = min(ans,ma-mi) print(ans)