結果
| 問題 |
No.1297 銅像
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 23:18:19 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,106 bytes |
| コンパイル時間 | 398 ms |
| コンパイル使用メモリ | 81,636 KB |
| 実行使用メモリ | 120,884 KB |
| 最終ジャッジ日時 | 2025-04-15 23:19:35 |
| 合計ジャッジ時間 | 11,344 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 6 WA * 15 |
ソースコード
def main():
import sys
input = sys.stdin.read().split()
idx = 0
N, C = int(input[idx]), int(input[idx+1])
idx += 2
a = []
b = []
for _ in range(N):
ai = int(input[idx])
bi = int(input[idx+1])
a.append(ai)
b.append(bi)
idx += 2
used = [False] * (N + 1) # 1-based indexing
total = 0
K = 200 # Adjust this value based on problem constraints
for j in range(1, N + 1):
min_cost = float('inf')
best_i = -1
start = max(1, j - K)
end = min(N, j + K)
for i in range(start, end + 1):
current_a = a[i - 1]
current_b = b[i - 1]
travel_cost = C * abs(i - j)
if not used[i]:
cost = current_b + current_a + travel_cost
else:
cost = current_a + travel_cost
if cost < min_cost:
min_cost = cost
best_i = i
total += min_cost
if not used[best_i]:
used[best_i] = True
print(total)
if __name__ == '__main__':
main()
lam6er