結果
| 問題 | No.3656 Game Scores and Costs |
| コンテスト | |
| ユーザー |
rinrion
|
| 提出日時 | 2026-08-30 21:54:04 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 2,000 ms |
| + 821µs | |
| コード長 | 1,120 bytes |
| 記録 | |
| コンパイル時間 | 2,417 ms |
| コンパイル使用メモリ | 250,056 KB |
| 実行使用メモリ | 9,784 KB |
| 最終ジャッジ日時 | 2026-08-30 21:54:22 |
| 合計ジャッジ時間 | 6,054 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
#define rep(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define repr(i, s, n) for (int i = (s); i >= (int)(n); --i)
#define sz(x) ((int)(x).size())
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
auto _ = []{ios::sync_with_stdio(false); cin.tie(nullptr); return 0;}();
const int INFI = 1 << 30;
const ll INFL = 1LL << 62;
int main() {
ll n, k, x;
cin >> n >> k >> x;
vl a (n);
rep(i, 0, n){
cin >> a[i];
}
ll mx=-INFL;
priority_queue<ll, vector<ll>, greater<ll>>q;
ll sm=0;
rep (i, 0, n){
sm+=a[i];
q.push(a[i]);
if(sz(q)>k){
sm-=q.top();
q.pop();
}
chmax(mx,sm-x*(i+1)) << '\n';
}
cout << mx << '\n';
return 0;
}
rinrion