結果

問題 No.9 モンスターのレベル上げ
ユーザー gew1fw
提出日時 2025-06-12 15:19:57
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,849 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 82,716 KB
実行使用メモリ 90,912 KB
最終ジャッジ日時 2025-06-12 15:20:33
合計ジャッジ時間 7,330 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 TLE * 3 -- * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

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):
        current_A = A.copy()
        selected = [False] * N
        counts = [0] * N
        
        for step in range(N):
            enemy = B[(s + step) % N]
            
            min_val = float('inf')
            min_indices = []
            for i in range(N):
                if current_A[i] < min_val:
                    min_val = current_A[i]
                    min_indices = [i]
                elif current_A[i] == min_val:
                    min_indices.append(i)
            
            found = False
            for i in min_indices:
                if not selected[i]:
                    selected[i] = True
                    counts[i] +=1
                    current_A[i] += (enemy // 2)
                    found = True
                    break
            if not found:
                for i in min_indices:
                    if not selected[i]:
                        selected[i] = True
                        counts[i] +=1
                        current_A[i] += (enemy // 2)
                        found = True
                        break
                if not found:
                    for i in min_indices:
                        selected[i] = True
                        counts[i] +=1
                        current_A[i] += (enemy // 2)
                        found = True
                        break
        
        max_count = max(counts)
        if max_count < min_max:
            min_max = max_count
        if min_max == 1:
            break
    
    print(min_max)
    return

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