This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// ./joi-2017-final-p2----semiexpress.yml
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const ll INF = 0x3f3f3f3f, LLINF = 0x3f3f3f3f3f3f3f3f;
const int MM = 3011;
int N, M, K;
ll A, B, C, T,
dp[MM][MM], gain[MM][MM], S[MM];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> N >> M >> K >> A >> B >> C >> T;
for (int i = 0; i < M; i++) cin >> S[i];
S[M] = N+1;
K -= M;
for (int i = 0; i < M; i++) {
ll add = 0, cur = S[i]-1;
for (int j = 0; j <= K; j++) {
ll init = (S[i]-1)*B + (cur+1-S[i])*C;
if (init > T) break;
ll nxt = min(cur+1 + (T-init) / A, S[i+1]-1);
// printf("i=%d j=%d init=%lld cur=%lld nxt=%lld add=%lld\n", i,j,init,cur,nxt,add+nxt-cur);
add += nxt - cur;
cur = nxt;
gain[i][j] = add;
}
}
for (int i = 0; i < M; i++) {
for (int j = 0; j <= K; j++) {
// printf("i=%d j=%d dp=%lld\n", i,j,dp[i][j]);
for (int k = 0; k <= K-j; k++) {
dp[i+1][j+k] = max(dp[i+1][j+k], dp[i][j] + gain[i][k]);
// printf("to i=%d j=%d k=%d gain=%lld\n", i+1,j+k,k,gain[i][k]);
}
}
}
// subtract station 1
cout << dp[M][K]-1 << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |