結果
問題 |
No.1460 Max of Min
|
ユーザー |
![]() |
提出日時 | 2025-04-16 00:15:38 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,460 bytes |
コンパイル時間 | 199 ms |
コンパイル使用メモリ | 81,620 KB |
実行使用メモリ | 76,468 KB |
最終ジャッジ日時 | 2025-04-16 00:17:31 |
合計ジャッジ時間 | 8,313 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 WA * 63 |
ソースコード
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 M = max(B) current = deque(A, maxlen=K) # Simulate up to 2*K steps beyond the initial K elements max_steps = 2 * K for step in range(K, max_steps + 1): if step > N: break # Check if current state can produce M has_condition = False for m in range(K): if B[m] == M and current[m] >= M: has_condition = True break if has_condition: print(M) return # Compute next value next_val = -float('inf') for m in range(K): val = min(current[m], B[m]) if val > next_val: next_val = val current.append(next_val) if step == N: print(next_val) return # After max_steps, check if all elements are <= B all_leq = True for m in range(K): if current[m] > B[m]: all_leq = False break if all_leq: X = max(current) print(X) else: # If not handled, return the last computed value (may not be correct for some cases) print(current[-1]) if __name__ == "__main__": main()