キーエンスプログラミングコンテスト2023秋(AtCoder Beginner Contest 325)
問題文
省略
省略
C++に変換後のコードはこちら
int @N, @D[N], @(L, C, K)[2];
int i, k, x, y;
ll dp[1001], nx[1001], res = ll_inf;
rep(i,1001) dp[i] = ll_inf;
dp[0] = 0;
rep(k,N){
rep(i,1001) nx[i] = ll_inf;
rep(x,1001){
y = max(cDiv(D[k] - x * L[0], L[1]), 0);
rep(i,x,1001) nx[i] <?= dp[i-x] + y;
if(y==0) break;
}
rep(i,1001) dp[i] = nx[i];
}
rep(i,K[0]+1) if(dp[i] <= K[1]) res <?= (ll) i * C[0] + dp[i] * C[1];
wt(if[res==ll_inf, -1, res]);
Current time: 2024年05月06日05時24分46秒
Last modified: 2023年10月22日11時01分08秒 (by laycrs)
Tags: Competitive_Programming_Incomplete AtCoder AtCoder_Beginner_Contest ABC325 ABC_F
トップページに戻る
Logged in as: unknown user (not login)