結果
問題 |
No.1460 Max of Min
|
ユーザー |
![]() |
提出日時 | 2025-06-12 16:34:41 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,258 bytes |
コンパイル時間 | 198 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 77,056 KB |
最終ジャッジ日時 | 2025-06-12 16:34:47 |
合計ジャッジ時間 | 6,008 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 TLE * 1 -- * 85 |
ソースコード
import sys from collections import deque def main(): K, N = map(int, sys.stdin.readline().split()) A = list(map(int, sys.stdin.readline().split())) B = list(map(int, sys.stdin.readline().split())) if N < K: print(A[N]) return # Initialize the deque with the first K elements dq = deque(A, maxlen=K) # We need to keep track of all elements until stabilization # or until N is reached. for i in range(K, N+1): # Compute the next element current_max = -float('inf') for j in range(K): a = dq[j] b = B[j] current_min = min(a, b) if current_min > current_max: current_max = current_min new_element = current_max # Add the new element to the deque dq.append(new_element) # Check if all elements in deque are the same as new_element all_same = True for elem in dq: if elem != new_element: all_same = False break if all_same: print(new_element) return # If we didn't break out early, output the last computed element print(dq[-1]) if __name__ == '__main__': main()