結果
| 問題 | No.3683 サーバー代がもったいない! |
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2026-09-09 05:05:47 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 55 ms / 2,000 ms |
| + 195µs | |
| コード長 | 916 bytes |
| 記録 | |
| コンパイル時間 | 2,047 ms |
| コンパイル使用メモリ | 333,920 KB |
| 実行使用メモリ | 90,240 KB |
| 最終ジャッジ日時 | 2026-09-09 05:05:58 |
| 合計ジャッジ時間 | 6,352 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#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--)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;
using u128=__int128_t;
using ll=long long;
ll dp[100100][55][2];
const ll INF=1e18;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
rep(i,100100) rep(j,55) rep(l,2) dp[i][j][l]=-INF;
int n,k;
cin>>n>>k;
V<ll> A(n);
rep(i,n) cin>>A[i];
dp[0][0][0]=0;
rep(i,n) rep(j,k+1){
dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][0]);
dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][1]);
if(dp[i][j][0]!=-INF && j+1<=k) dp[i+1][j+1][1]=max(dp[i+1][j+1][1],dp[i][j][0]+A[i]);
}
ll ans=max(dp[n][k][0],dp[n][k][1]);
if(ans==-INF) cout<<"Impossible"<<endl;
else cout<<ans<<endl;
return 0;
}
umezo