結果
問題 | No.2248 max(C)-min(C) |
ユーザー |
![]() |
提出日時 | 2025-03-26 15:46:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,088 ms / 3,000 ms |
コード長 | 1,573 bytes |
コンパイル時間 | 166 ms |
コンパイル使用メモリ | 82,564 KB |
実行使用メモリ | 180,816 KB |
最終ジャッジ日時 | 2025-03-26 15:48:25 |
合計ジャッジ時間 | 57,831 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
ソースコード
def main():import sysinput = sys.stdin.read().split()idx = 0N = int(input[idx])idx += 1A = list(map(int, input[idx:idx+N]))idx += NB = list(map(int, input[idx:idx+N]))idx += Npossible_x = Nonefor i in range(N):a = A[i]b = B[i]m = (a + b) // 2current = {a, b, m}if possible_x is None:possible_x = currentelse:possible_x &= currentif not possible_x:breakif possible_x:print(0)returncandidates = []for i in range(N):a = A[i]b = B[i]m = (a + b) // 2candidates.append((a, i))candidates.append((b, i))candidates.append((m, i))candidates.sort()freq = [0] * Ncount = 0min_length = float('inf')left = 0for right in range(len(candidates)):val, group = candidates[right]if freq[group] == 0:count += 1freq[group] += 1while count == N and left <= right:current_min = candidates[left][0]current_max = valcurrent_length = current_max - current_minif current_length < min_length:min_length = current_lengthleft_val, left_group = candidates[left]freq[left_group] -= 1if freq[left_group] == 0:count -= 1left += 1print(min_length)if __name__ == '__main__':main()