結果
| 問題 |
No.3050 Prefix Removal
|
| コンテスト | |
| ユーザー |
manuo
|
| 提出日時 | 2025-03-07 21:48:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 724 bytes |
| コンパイル時間 | 2,585 ms |
| コンパイル使用メモリ | 82,392 KB |
| 実行使用メモリ | 210,720 KB |
| 最終ジャッジ日時 | 2025-03-07 21:48:48 |
| 合計ジャッジ時間 | 12,643 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 45 RE * 4 |
ソースコード
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 = 0
for i in range(K-1):
cnt = A[cur]
cur += 1
while A[cur] < 0 and K-i-1 > N-cur-1:
cnt += A[cur]
cur += 1
ans += cnt*(i+1)
ans += (max(cum[cur+1:N+1])-cum[cur])*K
print(ans)
manuo