結果
| 問題 | No.3683 サーバー代がもったいない! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-05 13:47:14 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 120 ms / 2,000 ms |
| + 950µs | |
| コード長 | 1,093 bytes |
| 記録 | |
| コンパイル時間 | 3,954 ms |
| コンパイル使用メモリ | 382,628 KB |
| 実行使用メモリ | 133,092 KB |
| 最終ジャッジ日時 | 2026-09-05 13:51:10 |
| 合計ジャッジ時間 | 8,006 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using P=pair<ll,ll>;
typedef atcoder::modint mint;
ll inf=9e18;
template<typename T, int s, int i = 0>
auto vec(const ll (&sizes)[s], const T& init = T()){
if constexpr(i < s) return vector(sizes[i], vec<T, s, i+1>(sizes, init));
else return init;
}
int main(){
ll n,k;
cin>>n>>k;
if((n+1)/2<k){
cout<<"Impossible\n";
return 0;
}
auto v=vec<ll>({n},0);
for(ll i=0;i<n;i++){
cin>>v[i];
}
auto dp=vec<ll>({2,n+1,k+1},-inf);
dp[0][0][0]=0;
for(ll j=1;j<=n;j++){
for(ll l=0;l<=k;l++){
dp[0][j][l]=max({dp[0][j][l],dp[1][j-1][l],dp[0][j-1][l]});
if(l<k)dp[1][j][l+1]=max(dp[1][j][l+1],dp[0][j-1][l]+v[j-1]);
}
}
// for(ll i=0;i<2;i++){
// for(ll j=0;j<n+1;j++){
// for(ll l=0;l<k+1;l++){
// cout<<dp[i][j][l]<<" ";
// }
// cout<<"\n";
// }
// cout<<"\n";
// }
cout<<max(dp[0][n][k],dp[1][n][k])<<"\n";
}