結果
| 問題 | No.3050 Prefix Removal |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2025-02-02 14:49:48 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 240 ms / 2,000 ms |
| + 935µs | |
| コード長 | 391 bytes |
| 記録 | |
| コンパイル時間 | 99 ms |
| コンパイル使用メモリ | 65,000 KB |
| 実行使用メモリ | 133,088 KB |
| 最終ジャッジ日時 | 2026-10-21 05:37:18 |
| 合計ジャッジ時間 | 18,253 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 56 |
ソースコード
from heapq import *
n, K = map(int, input().split())
A = list(map(int, input().split()))
tot = 0
l_tot = 0
hq = []
ans = 0
for i, a in enumerate(A[:K], 1):
ans += i * a
for a in A:
tot += a
if len(hq) >= K - 1:
score = tot * K - l_tot
ans = max(ans, score)
l_tot += tot
heappush(hq, -tot)
if len(hq) == K:
l_tot += heappop(hq)
print(ans)