結果
| 問題 |
No.3050 Prefix Removal
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-07 22:54:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 733 bytes |
| コンパイル時間 | 2,138 ms |
| コンパイル使用メモリ | 198,804 KB |
| 実行使用メモリ | 12,848 KB |
| 最終ジャッジ日時 | 2025-03-07 22:54:36 |
| 合計ジャッジ時間 | 7,882 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 39 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,K; cin >> N >> K;
priority_queue<long long,vector<long long>,greater<>> Q;
long long answer = 0,now = 0;
vector<long long> A(K);
for(auto &a : A) cin >> a;
for(int i=K-1; i>=0; i--){
now += A.at(i)*(i+1);
if(i < K-1) A.at(i) += A.at(i+1);
if(i) Q.push(A.at(i));
}
answer = now;
long long zero = 0;
for(int i=K; i<N; i++){
long long a; cin >> a;
now += a*K;
if(Q.size()) now += zero-Q.top(),Q.pop();
answer = max(answer,now);
if(K > 1) Q.push(zero),zero -= a;
}
cout << answer << endl;
}