結果
| 問題 |
No.3050 Prefix Removal
|
| コンテスト | |
| ユーザー |
manuo
|
| 提出日時 | 2025-03-07 22:04:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 708 bytes |
| コンパイル時間 | 578 ms |
| コンパイル使用メモリ | 81,972 KB |
| 実行使用メモリ | 209,952 KB |
| 最終ジャッジ日時 | 2025-03-07 22:04:38 |
| 合計ジャッジ時間 | 12,113 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 WA * 45 |
ソースコード
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations
from heapq import heappop, heappush
import math, sys
# input = sys.stdin.readline
_int = lambda x: int(x)-1
MOD = 998244353 #10**9+7
INF = 1<<60
Yes, No = "Yes", "No"
N, K = map(int, input().split())
A = list(map(int, input().split()))
while A and len(A) > K:
if A[-1] < 0: A.pop()
else: break
N = len(A)
cum = [0]
for a in A: cum.append(cum[-1]+a)
ans = 0
cur = N-1
for i in reversed(range(1, K)):
cnt = A[cur]
cur -= 1
while A[cur] >= 0 and i <= cur:
cnt += A[cur]
cur -= 1
ans += cnt*(i+1)
ans += cum[cur+1]
print(ans)
manuo