結果

問題 No.9 モンスターのレベル上げ
ユーザー gew1fw
提出日時 2025-06-12 12:53:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,284 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 85,628 KB
最終ジャッジ日時 2025-06-12 12:55:21
合計ジャッジ時間 6,975 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    N = int(sys.stdin.readline())
    A = list(map(int, sys.stdin.readline().split()))
    B = list(map(int, sys.stdin.readline().split()))
    
    min_max = float('inf')
    
    for start in range(N):
        enemy_order = B[start:] + B[:start]
        current_levels = A.copy()
        selected = [False] * N
        counts = [0] * N
        
        for b in enemy_order:
            m = min(current_levels)
            selected_i = -1
            # Check unselected monsters first
            for i in range(N):
                if not selected[i] and current_levels[i] == m:
                    selected_i = i
                    break
            # If no unselected found, check all
            if selected_i == -1:
                for i in range(N):
                    if current_levels[i] == m:
                        selected_i = i
                        break
            counts[selected_i] += 1
            selected[selected_i] = True
            current_levels[selected_i] += b // 2
        
        current_max = max(counts)
        if current_max < min_max:
            min_max = current_max
            # Early exit if possible
            if min_max == 1:
                break
    
    print(min_max)

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