結果
| 問題 | No.3683 サーバー代がもったいない! |
| コンテスト | |
| ユーザー |
よには
|
| 提出日時 | 2026-07-11 13:19:36 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 318 ms / 2,000 ms |
| + 204µs | |
| コード長 | 1,282 bytes |
| 記録 | |
| コンパイル時間 | 6,219 ms |
| コンパイル使用メモリ | 417,744 KB |
| 実行使用メモリ | 286,464 KB |
| 最終ジャッジ日時 | 2026-09-05 12:36:33 |
| 合計ジャッジ時間 | 13,793 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#if __has_include(<yoniha/all.h>)
#include <yoniha/all.h>
using namespace atcoder;
#else
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#endif
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)((n) - 1); i >= 0; i--)
template <typename T> bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template <typename T> bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
// using mint = modint;
signed main(){
int n, k; cin >> n >> k;
vector<int> a(n); for(auto&& ai : a) cin >> ai;
if((n + 1) / 2 < k){
println("Impossible");
return 0;
}
// i個見てj個消してて(k?i個目を消した:消してない)ときの最大値
const int inf = 1ll << 60;
vector dp(n + 1, vector(k + 1, vector(2, -inf)));
dp.at(0).at(0).at(0) = 0;
rep(i, n){
auto ai = a.at(i);
rep(j, k + 1){
chmax(dp.at(i + 1).at(j).at(0), *max_element(all(dp.at(i).at(j))));
}
rep(j, k){
chmax(dp.at(i + 1).at(j + 1).at(1), dp.at(i).at(j).at(0) + ai);
}
}
println("{}", *max_element(all(dp.back().back())));
}
/*
(n+1)/2<kなら無理
*/
よには