結果
| 問題 | No.3683 サーバー代がもったいない! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-05 13:36:34 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 725 bytes |
| 記録 | |
| コンパイル時間 | 2,334 ms |
| コンパイル使用メモリ | 360,100 KB |
| 実行使用メモリ | 285,568 KB |
| 最終ジャッジ日時 | 2026-09-05 13:36:45 |
| 合計ジャッジ時間 | 8,935 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, K;
cin >> N >> K;
vector dp(N + 1, vector(K + 1, vector<ll>(2, LLONG_MIN)));
dp[0][0][0] = 0;
auto chmax = [&](ll& a, ll b) { a = max(a, b); };
for(int i=0; i<N; i++) {
ll A; cin >> A;
for(int k=0; k<K; k++) for(int f=0; f<=1; f++) {
if(dp[i][k][f] == LLONG_MIN) continue;
chmax(dp[i+1][k][0], dp[i][k][f]);
if(!f) chmax(dp[i+1][k+1][1-f], dp[i][k][f] + A);
}
}
ll ans = max(dp[N][K][0], dp[N][K][1]);
if(ans == LLONG_MIN) cout << "Impossible" << endl;
else cout << ans << endl;
}