結果
| 問題 | No.3683 サーバー代がもったいない! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-10 18:39:34 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,032 bytes |
| 記録 | |
| コンパイル時間 | 3,524 ms |
| コンパイル使用メモリ | 359,876 KB |
| 実行使用メモリ | 285,952 KB |
| 最終ジャッジ日時 | 2026-09-05 12:33:27 |
| 合計ジャッジ時間 | 9,095 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (ll i = (a); i < (ll)(b); i++)
#define all(x) x.begin(), x.end()
const ll INF = 1001001001001001001;
template <typename T>
inline bool chmax(T& a, const T& b) {
return ((a < b) ? (a = b, true) : (false));
}
void solve() {
int N, K;
cin >> N >> K;
vector<int> A(N);
rep(i, 0, N) cin >> A[i];
if (K * 2 - 1 > N) {
cout << "Impossible\n";
return;
}
vector dp(N + 1, vector(K + 1, vector<ll>(2, -INF)));
dp[0][0][0] = 0;
rep(i, 0, N) {
rep(j, 0, K) {
chmax(dp[i + 1][j][0], dp[i][j][0]);
chmax(dp[i + 1][j][0], dp[i][j][1]);
chmax(dp[i + 1][j + 1][1], dp[i][j][0] + A[i]);
}
}
ll ans = -INF;
chmax(ans, dp[N][K][0]);
chmax(ans, dp[N][K][1]);
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T = 1;
// cin >> T;
while (T--) {
solve();
}
}