結果
問題 |
No.3050 Prefix Removal
|
ユーザー |
![]() |
提出日時 | 2025-03-07 21:52:11 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 723 bytes |
コンパイル時間 | 622 ms |
コンパイル使用メモリ | 82,368 KB |
実行使用メモリ | 210,852 KB |
最終ジャッジ日時 | 2025-03-07 21:52:24 |
合計ジャッジ時間 | 12,423 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 = 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)