# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
299316 | BeanZ | Semiexpress (JOI17_semiexpress) | C++14 | 23 ms | 2168 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 1e5 + 5;
ll dp[305][305];
ll s[305], len[305], p[305], last[305];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("A.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ll n, m, k;
cin >> n >> m >> k;
ll A, B, C;
cin >> A >> B >> C;
ll T;
cin >> T;
for (int i = 1; i <= m; i++) cin >> s[i];
len[1] = 0;
ll cur = 1;
for (int i = 1; i <= n; i++){
last[i] = cur;
if ((cur + 1) <= m && s[cur + 1] <= i) cur++;
len[i] = (s[cur] - 1) * B + (i - s[cur]) * C;
ll dist = len[i];
if (dist <= T) p[i] = 1;
else p[i] = 0;
for (int j = i + 1; j <= n; j++){
dist = dist + A;
if (dist > T) break;
p[i]++;
}
//cout << last[i] << " " << p[i] << endl;
}
//cout << endl << endl;
ll ans = 0;
for (int i = 1; i <= n; i++){
for (int j = 0; j <= k; j++) dp[i][j] = -1e9;
}
dp[1][1] = p[1];
for (int i = 2; i <= n; i++){
for (int j = 1; j <= k; j++){
for (int t = s[last[i]]; t < i; t++){
dp[i][j] = max(dp[i][j], dp[t][j - 1] - p[t] + min((ll)(i - t), p[t]) + p[i]);
ans = max(ans, dp[i][j]);
cout << i << " " << j << " " << dp[i][j] << endl;
}
}
}
cout << ans - 1;
}
/*
eraae
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |