Educational Codeforces Round 96 F問題
Problem description
省略
省略
C++に変換後のコードはこちら
//no-unlocked
int N; ll K, L[2000], R[2000], A[2000];
ll dp[2001];
{
ll t, r, us, em, d;
rd(N,K,(L,R,A)(N));
rep(i,1,N+1) dp[i] = ll_inf;
rep(i,N){
(t, r, us, em) = (0, K, 0, 0);
rep(j,i,N){
t >?= L[j];
em += A[j];
d = min(em, r);
(em, r) -= d;
us += d;
d = em /+ K;
t += d;
r += d*K;
d = min(em, r);
(em, r) -= d;
us += d;
if(t > R[j]) break;
if(j==N-1 && t <= R[j]) dp[j+1] <?= dp[i] + us;
if(j!=N-1 && t+1 <= L[j+1]) dp[j+1] <?= dp[i] + us + r;
}
}
wt(if[dp[N]==ll_inf, -1, dp[N]]);
}
Current time: 2024年04月25日18時56分32秒
Last modified: 2020年11月03日23時02分46秒 (by laycrs)
Tags: Competitive_Programming_Incomplete Codeforces
トップページに戻る
Logged in as: unknown user (not login)