結果
| 問題 | No.2028 Even Choice |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-24 23:10:42 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 2,000 ms |
| コード長 | 449 bytes |
| 記録 | |
| コンパイル時間 | 1,213 ms |
| コンパイル使用メモリ | 214,588 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-27 17:34:47 |
| 合計ジャッジ時間 | 3,444 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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';
}