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 <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>
using namespace std;
#define int long long
const int N = 3001;
const int INF = 1e18 + 239;
int dp[N][N];
int n, k;
int lc, ex, sm;
int t;
vector<int> proc(int sd, int len) {
if (sd >= t) {
return {0};
}
int wd = sd;
int delta = t - sd;
int can = delta / lc;
vector<int> ret = {can};
sd += (can) * sm;
if (ret.back() < len) {
for (int i = 0; i < k; i++) {
sd += sm;
if (sd > t) {
break;
}
can = (t - sd) / lc;
ret.push_back(ret.back() + can + 1);
sd += can * sm;
if (ret.back() > len) {
ret.back() = len;
break;
}
}
} else {
ret.back() = len;
}
for (auto &x : ret) {
if (x < len && wd + len * ex <= t) {
x++;
}
}
return ret;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
dp[i][j] = -INF;
}
}
int m;
cin >> n >> m >> k;
k -= m;
cin >> lc >> ex >> sm;
cin >> t;
vector<int> s(m);
for (auto &x : s) {
cin >> x;
x--;
}
dp[0][0] = 0;
int ans = 0;
vector<int> v;
for (int i = 1; i < m; i++) {
int len = s[i] - s[i - 1];
int sd = s[i - 1] * ex;
auto nw = proc(sd, len);
if (nw.empty()) continue;
vector<int> dl = {};
for (int j = 1; j < (int)nw.size(); j++) {
dl.push_back(nw[j] - nw[j - 1]);
}
ans += nw[0];
for (auto x : dl) {
v.push_back(x);
}
}
sort(v.rbegin(), v.rend());
for (int i = 0; i < min((int)v.size(), k); i++) {
ans += v[i];
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |