#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 |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
412 KB |
Output is correct |
4 |
Correct |
2 ms |
464 KB |
Output is correct |
5 |
Correct |
3 ms |
556 KB |
Output is correct |
6 |
Correct |
2 ms |
560 KB |
Output is correct |
7 |
Correct |
2 ms |
564 KB |
Output is correct |
8 |
Correct |
3 ms |
568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
412 KB |
Output is correct |
4 |
Correct |
2 ms |
464 KB |
Output is correct |
5 |
Correct |
3 ms |
556 KB |
Output is correct |
6 |
Correct |
2 ms |
560 KB |
Output is correct |
7 |
Correct |
2 ms |
564 KB |
Output is correct |
8 |
Correct |
3 ms |
568 KB |
Output is correct |
9 |
Correct |
3 ms |
700 KB |
Output is correct |
10 |
Correct |
2 ms |
700 KB |
Output is correct |
11 |
Correct |
3 ms |
740 KB |
Output is correct |
12 |
Correct |
4 ms |
752 KB |
Output is correct |
13 |
Correct |
3 ms |
772 KB |
Output is correct |
14 |
Correct |
2 ms |
816 KB |
Output is correct |
15 |
Correct |
2 ms |
876 KB |
Output is correct |
16 |
Correct |
2 ms |
880 KB |
Output is correct |
17 |
Correct |
3 ms |
884 KB |
Output is correct |
18 |
Correct |
2 ms |
1012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
412 KB |
Output is correct |
4 |
Correct |
2 ms |
464 KB |
Output is correct |
5 |
Correct |
3 ms |
556 KB |
Output is correct |
6 |
Correct |
2 ms |
560 KB |
Output is correct |
7 |
Correct |
2 ms |
564 KB |
Output is correct |
8 |
Correct |
3 ms |
568 KB |
Output is correct |
9 |
Correct |
3 ms |
700 KB |
Output is correct |
10 |
Correct |
2 ms |
700 KB |
Output is correct |
11 |
Correct |
3 ms |
740 KB |
Output is correct |
12 |
Correct |
4 ms |
752 KB |
Output is correct |
13 |
Correct |
3 ms |
772 KB |
Output is correct |
14 |
Correct |
2 ms |
816 KB |
Output is correct |
15 |
Correct |
2 ms |
876 KB |
Output is correct |
16 |
Correct |
2 ms |
880 KB |
Output is correct |
17 |
Correct |
3 ms |
884 KB |
Output is correct |
18 |
Correct |
2 ms |
1012 KB |
Output is correct |
19 |
Correct |
3 ms |
1012 KB |
Output is correct |
20 |
Correct |
3 ms |
1012 KB |
Output is correct |
21 |
Correct |
3 ms |
1012 KB |
Output is correct |
22 |
Correct |
3 ms |
1012 KB |
Output is correct |
23 |
Correct |
20 ms |
1012 KB |
Output is correct |
24 |
Correct |
4 ms |
1024 KB |
Output is correct |
25 |
Correct |
3 ms |
1036 KB |
Output is correct |
26 |
Correct |
3 ms |
1048 KB |
Output is correct |
27 |
Correct |
4 ms |
1068 KB |
Output is correct |
28 |
Correct |
3 ms |
1084 KB |
Output is correct |
29 |
Correct |
8 ms |
1100 KB |
Output is correct |
30 |
Correct |
6 ms |
1236 KB |
Output is correct |