結果

問題 No.3014 岩井満足性問題
ユーザー cho435
提出日時 2025-02-22 02:08:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 446 ms / 3,000 ms
コード長 858 bytes
コンパイル時間 4,767 ms
コンパイル使用メモリ 254,784 KB
実行使用メモリ 7,220 KB
最終ジャッジ日時 2025-02-22 02:08:35
合計ジャッジ時間 6,409 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)

template<typename T>
bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; }
template<typename T>
bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; }

struct io_setup {
	io_setup() {
		ios::sync_with_stdio(false);
		std::cin.tie(nullptr);
		cout << fixed << setprecision(15);
	}
} io_setup;

int main(){
	ll n,d,k;
	cin>>n>>d>>k;
	vector<int> a(n),c(n);
	rep(i,0,n) cin>>a[i];
	rep(i,0,n) cin>>c[i];
	vector dp(d+1,vector<ll>(k+1,-1e18));
	dp[0][0]=0;
	rep(i,0,n){
		auto ndp=dp;
		rep(jj,0,d){
			rep(j,0,k+1){
				if(dp[jj][j]==-1e18) continue;
				chmax(ndp[jj+1][min(k,j+c[i])],dp[jj][j]+a[i]);
			}
		}
		swap(ndp,dp);
	}
	if(dp[d][k]==-1e18) cout<<"No\n";
	else cout<<dp[d][k]<<"\n";
}
0