# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68400 | BThero | Semiexpress (JOI17_semiexpress) | C++17 | 36 ms | 1116 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.
// Why I am so dumb? :c
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int MAXN = (int)3e2 + 5;
int dp[MAXN][MAXN];
bool good[MAXN];
int p[MAXN];
int n, m, k;
int a, b, c;
int lim;
void solve() {
scanf("%d %d %d", &n, &m, &k);
scanf("%d %d %d", &a, &b, &c);
scanf("%d", &lim);
for (int i = 1, x; i <= m; ++i) {
scanf("%d", &x);
good[x] = 1;
}
for (int i = 1, v = 1; i <= n; ++i) {
if (good[i]) {
v = i;
}
p[i] = v;
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= k; ++j) {
dp[i][j] = -n;
}
}
dp[1][1] = 0;
for (int i = 2; i <= n; ++i) {
for (int j = 2; j <= k; ++j) {
for (int pr = p[i - 1]; pr < i; ++pr) {
int cost = (p[i - 1] - 1) * b + (pr - p[i - 1]) * c;
int cnt = 0;
for (int x = pr + 1; x < i; ++x) {
if (cost + (x - pr) * a <= lim) {
++cnt;
}
}
if (good[i]) {
if ((i - 1) * b <= lim) {
++cnt;
}
}
else {
if (cost + (i - pr) * c <= lim) {
++cnt;
}
}
dp[i][j] = max(dp[i][j], dp[pr][j - 1] + cnt);
}
}
}
printf("%d\n", dp[n][k]);
}
int main() {
int tt = 1;
while (tt--) {
solve();
}
return 0;
}
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... |