結果

問題 No.1297 銅像
ユーザー gew1fw
提出日時 2025-06-12 21:37:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 722 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,032 KB
実行使用メモリ 65,964 KB
最終ジャッジ日時 2025-06-12 21:40:42
合計ジャッジ時間 5,664 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 2 WA * 5 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    C = int(input[idx])
    idx +=1
    workers = []
    for i in range(N):
        a = int(input[idx])
        b = int(input[idx+1])
        idx +=2
        workers.append( (a, b) )
    
    min_total = float('inf')
    for i in range(N):
        a_i, b_i = workers[i]
        total = b_i
        total += a_i * N
        cost = 0
        for j in range(1, N+1):
            distance = abs(j - (i+1))  # i+1是岛的编号,从1到N
            cost += distance * C
        total += cost
        if total < min_total:
            min_total = total
    print(min_total)

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