結果

問題 No.1460 Max of Min
ユーザー gew1fw
提出日時 2025-06-12 21:35:56
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 641 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 82,296 KB
実行使用メモリ 83,748 KB
最終ジャッジ日時 2025-06-12 21:38:18
合計ジャッジ時間 5,550 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 1 -- * 85
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read().split()
    ptr = 0
    K = int(input[ptr])
    ptr +=1
    N = int(input[ptr])
    ptr +=1
    
    A = list(map(int, input[ptr:ptr+K]))
    ptr +=K
    B = list(map(int, input[ptr:ptr+K]))
    ptr +=K
    
    if N < K:
        print(A[N])
        return
    
    state = A.copy()
    for step in range(K, N + 1):
        new_val = max(min(state[j], B[j]) for j in range(K))
        state.pop(0)
        state.append(new_val)
        if all(x == state[0] for x in state):
            print(state[0])
            return
    
    print(state[-1])

if __name__ == "__main__":
    main()
0