結果

問題 No.1460 Max of Min
ユーザー gew1fw
提出日時 2025-06-12 16:33:23
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 956 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,340 KB
実行使用メモリ 58,948 KB
最終ジャッジ日時 2025-06-12 16:33:49
合計ジャッジ時間 4,383 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 TLE * 1 -- * 87
権限があれば一括ダウンロードができます

ソースコード

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
    
    c = max(B)
    j_list = [j for j in range(K) if B[j] == c]
    
    current_window = A.copy()
    
    for i in range(K, N + 1):
        found = False
        for j in j_list:
            if current_window[j] >= c:
                found = True
                break
        if found:
            if i <= N:
                print(c)
            return
        else:
            min_values = [min(current_window[j], B[j]) for j in range(K)]
            A_i = max(min_values)
            current_window.pop(0)
            current_window.append(A_i)
            if i == N:
                print(A_i)
                return
    
main()
0