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 pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define ld long double
#define s second
#define vec vector<int>
using namespace std;
const int N = (int) 2e3 + 100;
const int M = (int) 2018 * 2018;
const int K = (int) 10;
const int INF = (int) 1e9 + 7;
const int mod = (int) 998244353;
const ld EPS = (ld) 1e-9;
const ll LINF = (ll) 1e18;
ll n, m, k;
ll A, B, C, T;
ll x[N];
ll dist[N], L[N];
int main() {
#ifdef sony
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
srand(time(0));
cin >> n >> m >> k;
cin >> A >> B >> C;
cin >> T;
ll ans = 0;
for (int i = 1; i <= m; i++) {
cin >> x[i];
}
for (int i = 1; i <= m; i++) {
if (x[i] > 1 && T - (x[i] - 1) * B >= 0) ans++;
dist[i] = (T - (x[i] - 1) * B);
if (dist[i] < 0) continue;
ll l = x[i] + dist[i] / A + 1, r = x[i + 1];
L[i] = min(l, r);
}
for (int iter = 1; iter <= k - m; iter++) {
int id = -1;
ll mx = 0;
for (int i = 1; i < m; i++) {
if (dist[i] < 0) continue;
// put express at L[i] and count how much will be added
ll cost = T - ((x[i] - 1) * B + (L[i] - x[i]) * C);
if (cost < 0 || L[i] == x[i + 1]) continue;
ll cnt = max(0ll, min(x[i + 1] - 1 - L[i], cost / A)) + 1; // (l,l+cost/A)
if (cnt > mx) {
mx = cnt;
id = i;
}
}
if (id == -1) break;
//cout << " optimus " << id << ' ' << mx << ' ' << L[id] << endl;
ll cost = T - ((x[id] - 1) * B + (L[id] - x[id]) * C);
ll cnt = max(0ll, min(x[id + 1] - 1 - L[id], cost / A)) + 1; // (l,l+cost/A)
L[id] += cnt;
}
for (int i = 1; i < m; i++) {
//cout << L[i] << ' ' << x[i] << endl;
if (dist[i] >= 0)
ans += max(0ll, L[i] - x[i] - 1);
}
cout << ans;
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... |