結果
| 問題 | 
                            No.1460 Max of Min
                             | 
                    
| コンテスト | |
| ユーザー | 
                             gew1fw
                         | 
                    
| 提出日時 | 2025-06-12 14:35:38 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,658 bytes | 
| コンパイル時間 | 229 ms | 
| コンパイル使用メモリ | 82,212 KB | 
| 実行使用メモリ | 126,272 KB | 
| 最終ジャッジ日時 | 2025-06-12 14:36:20 | 
| 合計ジャッジ時間 | 15,630 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 69 WA * 22 | 
ソースコード
def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    K = int(input[idx])
    idx += 1
    N = int(input[idx])
    idx += 1
    A = list(map(int, input[idx:idx+K]))
    idx += K
    B = list(map(int, input[idx:idx+K]))
    idx += K
    if N < K:
        print(A[N])
        return
    window = A.copy()
    recent = []
    seen = dict()
    cycle_check_length = 100  # Adjust this based on possible cycle lengths
    for i in range(K, N + 1):
        new_element = max(min(window[j], B[j]) for j in range(K))
        # Update the window
        window.pop(0)
        window.append(new_element)
        # Update recent elements for cycle detection
        recent.append(new_element)
        if len(recent) > cycle_check_length:
            recent.pop(0)
        # Check for cycle
        current_hash = tuple(recent)
        if current_hash in seen:
            prev_step = seen[current_hash]
            cycle_length = i - prev_step
            remaining = N - i
            if remaining <= 0:
                break
            total_cycles = remaining // cycle_length
            i += total_cycles * cycle_length
            remaining = remaining % cycle_length
            # Simulate remaining steps
            for _ in range(remaining):
                new_element = max(min(window[j], B[j]) for j in range(K))
                window.pop(0)
                window.append(new_element)
                i += 1
                if i > N:
                    break
            break
        else:
            seen[current_hash] = i
        if i == N:
            break
    print(window[-1])
if __name__ == "__main__":
    main()
            
            
            
        
            
gew1fw