結果
問題 | No.2918 Divide Applicants Fairly |
ユーザー |
![]() |
提出日時 | 2024-10-08 01:29:41 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 980 bytes |
コンパイル時間 | 369 ms |
コンパイル使用メモリ | 81,600 KB |
実行使用メモリ | 599,124 KB |
最終ジャッジ日時 | 2024-10-08 01:29:46 |
合計ジャッジ時間 | 4,140 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | MLE * 1 -- * 60 |
ソースコード
import bisectN = int(input())R = list(map(int, input().split()))FR,SR = R[:N//2],R[N//2:]FRSB = [set() for _ in range(22)]SRSB = [set() for _ in range(22)]for fr in FR:for i in reversed(range(21)):for frsl in list(FRSB[i]):FRSB[i+1].add(frsl+fr)FRSB[i+1].add(frsl-fr)FRSB[0].add(fr)FRSB[0].add(-fr)for sr in SR:for i in reversed(range(21)):for srsl in list(SRSB[i]):SRSB[i+1].add(srsl+sr)SRSB[i+1].add(srsl-sr)SRSB[0].add(sr)SRSB[0].add(-sr)ans = 10**18for k in range(21):FRS = sorted(FRSB[k])SRS = sorted(SRSB[k])for frs in FRS:i = bisect.bisect_left(SRS,frs)if 0<i:ans = min(ans,frs-SRS[i-1])if i<len(SRS)-1:ans = min(ans,SRS[i]-frs)if k%2==0:for i,j in zip(FRS,FRS[1:]):ans = min(ans,j-i)for i,j in zip(SRS,SRS[1:]):ans = min(ans,j-i)print(ans)