結果
問題 | No.3014 岩井満足性問題 |
ユーザー |
|
提出日時 | 2025-01-25 12:56:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 278 ms / 3,000 ms |
コード長 | 520 bytes |
コンパイル時間 | 778 ms |
コンパイル使用メモリ | 61,824 KB |
実行使用メモリ | 5,632 KB |
最終ジャッジ日時 | 2025-01-25 22:27:05 |
合計ジャッジ時間 | 1,913 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include<iostream> #include<cassert> using namespace std; int N,D,K; int A[500]; long dp[501][501]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>D>>K; for(int i=0;i<N;i++)cin>>A[i]; for(int i=0;i<=D;i++)for(int j=0;j<=K;j++)dp[i][j]=-1e18; dp[0][0]=0; for(int i=0;i<N;i++) { int C;cin>>C; for(int j=D-1;j>=0;j--)for(int k=0;k<=K;k++) { int nk=min(k+C,K); dp[j+1][nk]=max(dp[j+1][nk],dp[j][k]+A[i]); } } long v=dp[D][K]; if(v<-1e15)cout<<"No"<<endl; else cout<<v<<endl; }