結果

問題 No.2028 Even Choice
ユーザー どららどらら
提出日時 2022-08-05 23:03:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 822 bytes
コンパイル時間 5,347 ms
コンパイル使用メモリ 229,560 KB
実行使用メモリ 7,008 KB
最終ジャッジ日時 2023-10-14 00:46:00
合計ジャッジ時間 7,413 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
5,964 KB
testcase_01 AC 88 ms
6,660 KB
testcase_02 AC 93 ms
5,792 KB
testcase_03 AC 86 ms
7,008 KB
testcase_04 AC 87 ms
6,884 KB
testcase_05 AC 20 ms
4,352 KB
testcase_06 AC 82 ms
5,640 KB
testcase_07 AC 24 ms
4,372 KB
testcase_08 AC 56 ms
4,524 KB
testcase_09 AC 63 ms
5,180 KB
testcase_10 AC 23 ms
4,376 KB
testcase_11 AC 17 ms
4,348 KB
testcase_12 AC 8 ms
4,352 KB
testcase_13 AC 65 ms
6,336 KB
testcase_14 AC 25 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 1 ms
4,356 KB
testcase_17 AC 1 ms
4,352 KB
testcase_18 AC 1 ms
4,352 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 1 ms
4,352 KB
testcase_24 AC 1 ms
4,352 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,352 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 51 ms
4,352 KB
testcase_29 AC 34 ms
4,348 KB
testcase_30 AC 23 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
//using mint = modint1000000007;
//using mint = modint998244353;



int main(){
  int N, K;
  cin >> N >> K;
  vector<ll> v(N);
  rep(i,N) cin >> v[i];

  ll ret = 0;
  ll sum = 0;
  priority_queue<ll,vector<ll>,greater<ll>> que;
  for(int i=N-1; i>=0; i--){
    if(i%2 == 1){
      ret = max(ret, v[i] + sum);
    }
    sum += v[i];
    que.push(v[i]);
    if(que.size() >= K){
      sum -= que.top();
      que.pop();
    }
  }
  
  cout << ret << endl;
  
  return 0;
}

0