結果

問題 No.9 モンスターのレベル上げ
ユーザー gew1fw
提出日時 2025-06-12 15:17:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,279 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 82,516 KB
実行使用メモリ 99,656 KB
最終ジャッジ日時 2025-06-12 15:18:10
合計ジャッジ時間 25,433 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 WA * 1 TLE * 3 -- * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    A = list(map(int, input[idx:idx+N]))
    idx += N
    B = list(map(int, input[idx:idx+N]))
    idx += N

    min_max = float('inf')

    for s in range(N):
        # Generate the order of B starting at s
        order = []
        for i in range(N):
            order.append(B[(s + i) % N])

        current_level = A.copy()
        count = [0] * N

        for b in order:
            # Find the monster with minimal current level, and smallest index if tie
            min_level = float('inf')
            selected = -1
            for i in range(N):
                if current_level[i] < min_level:
                    min_level = current_level[i]
                    selected = i
                elif current_level[i] == min_level:
                    if i < selected:
                        selected = i

            # Update the selected monster
            exp = b // 2
            current_level[selected] += exp
            count[selected] += 1

        # Compute the maximum count
        current_max = max(count)
        if current_max < min_max:
            min_max = current_max

    print(min_max)

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