結果
| 問題 | No.3656 Game Scores and Costs |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-30 13:58:30 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 99 ms / 2,000 ms |
| + 822µs | |
| コード長 | 1,032 bytes |
| 記録 | |
| コンパイル時間 | 4,445 ms |
| コンパイル使用メモリ | 388,704 KB |
| 実行使用メモリ | 14,464 KB |
| 最終ジャッジ日時 | 2026-08-30 13:58:40 |
| 合計ジャッジ時間 | 7,824 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using mint = modint998244353;
ll MOD=998244353;
#define all(x) x.begin(), x.end()
#define rep(i, n) for(ll i = 0; (i) < (n); (i)++)
template<class T>
auto comp_idx(const T* ptr){
return [ptr](auto l_idx, auto r_idx){
return ptr[l_idx] < ptr[r_idx];
};
}
template<class T>
vector<ll> IndexSort(T vec){
vector<ll> ind(vec.size());
iota(all(ind), 0);
sort(all(ind), comp_idx(vec.data()));
return ind;
}
void yn(bool flag){
string ans = (flag) ? "Yes" : "No";
cout<<ans<<endl;
}
int main(){
ll n, k, x; cin>>n>>k>>x;
vector<ll> A(n);
rep(i, n){
cin>>A[i];
}
multiset<ll> mem;
ll ans=A[0]-x;
ll now=A[0];
mem.insert(A[0]);
rep(i, n-1){
now+=A[i+1];
mem.insert(A[i+1]);
if(mem.size()>k){
now-=*mem.begin();
mem.erase(mem.begin());
}
ans=max(ans, now-x*(i+2));
//cout<<ans<<endl;
}
cout<<ans<<endl;
}