結果

問題 No.9 モンスターのレベル上げ
ユーザー lam6er
提出日時 2025-04-16 15:44:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,049 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 82,324 KB
実行使用メモリ 104,060 KB
最終ジャッジ日時 2025-04-16 15:47:19
合計ジャッジ時間 6,894 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# Precompute the enemy order for each starting point
order = [B[i:] + B[:i] for i in range(n)]

min_max = float('inf')

for start in range(n):
    current_A = A.copy()
    used = [False] * n
    count = [0] * n
    enemies = order[start]
    
    for b in enemies:
        current_min = min(current_A)
        # Collect all candidates with current_min
        candidates = []
        unused = []
        for j in range(n):
            if current_A[j] == current_min:
                candidates.append(j)
                if not used[j]:
                    unused.append(j)
        # Determine the selected monster
        if unused:
            selected = min(unused)
        else:
            selected = min(candidates)
        # Update count and used
        count[selected] += 1
        used[selected] = True
        current_A[selected] += b // 2
    
    current_max = max(count)
    if current_max < min_max:
        min_max = current_max

print(min_max)
0