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>
#define FOR(x, a, b) for (int x = a; x <= b; ++x)
#define FOD(x, a, b) for (int x = a; x >= b; --x)
#define REP(x, a, b) for (int x = a; x < b; ++x)
#define DEBUG(X) { cout << #X << " = " << X << endl; }
#define PR(A, n) { cout << #A << " = "; FOR(_, 1, n) cout << A[_] << " "; cout << endl; }
#define PR0(A, n) { cout << #A << " = "; REP(_, 0, n) cout << A[_] << " "; cout << endl; }
#define BitCount(x) __builtin_popcount(x)
using namespace std;
typedef long long LL;
const int N = 3e3 + 10;
int n, m, k, PA, PB, PC;
int a[N];
int f[N][N], pos[N][N], dp[N][N];
LL t;
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // LOCAL
scanf("%d%d%d", &n, &m, &k); k -= m;
scanf("%d%d%d", &PA, &PB, &PC);
scanf("%lld", &t);
FOR(i, 1, m) scanf("%d", &a[i]);
// sort(a + 1, a + m + 1); m = unique(a + 1, a + m + 1) - a - 1;
FOR(i, 1, m - 1) {
LL restTime = t - (LL)PB * (a[i] - a[1]);
if (restTime <= 0) break;
int x = a[i];
FOR(j, 0, k) {
if (restTime <= 0) {
int v = f[i][j - 1] + (restTime == 0);
FOR(p, j, k) f[i][p] = v;
break;
}
int y = (restTime + (LL)x * PA) / PA;
if (y >= a[i + 1] - 1) {
FOR(p, j, k) f[i][p] = a[i + 1] - 1 - a[i];
break;
}
f[i][j] = y - a[i];
restTime -= (LL)(y + 1 - x) * PC;
x = y + 1;
}
}
FOR(i, 1, m - 1) {
LL restTime = t - (LL)PB * (a[i] - a[1]);
if (restTime <= 0) {
printf("%d", dp[i - 1][k] + (restTime == 0) - 1);
return 0;
}
FOR(j, 0, k)
FOR(x, 0, j) dp[i][j] = max(dp[i][j], dp[i - 1][j - x] + f[i][x] + 1);
}
printf("%d\n", dp[m - 1][k] + (t - (LL)PB * (a[m] - a[1]) >= 0) - 1);
return 0;
}
Compilation message (stderr)
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:28:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &n, &m, &k); k -= m;
^
semiexpress.cpp:29:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &PA, &PB, &PC);
^
semiexpress.cpp:30:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &t);
^
semiexpress.cpp:31:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
FOR(i, 1, m) scanf("%d", &a[i]);
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |