結果
| 問題 |
No.2028 Even Choice
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-24 23:10:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 449 bytes |
| コンパイル時間 | 2,107 ms |
| コンパイル使用メモリ | 197,848 KB |
| 最終ジャッジ日時 | 2025-02-07 14:33:38 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,K;
cin>>N>>K;
vector<int>A(N);
for(int &i:A)cin>>i;
long long ans=0,now=0;
priority_queue<int,vector<int>,greater<int>>a;
for(int i=N-1;i>=0;i--){
if(i%2){
ans=max(ans,now+A[i]);
}
now+=A[i];
a.push(A[i]);
while(a.size()>K-1){
now-=a.top();
a.pop();
}
}
cout<<ans<<'\n';
}