#pragma gcc optimize("Ofast")
#include <vector>
#pragma gcc target("avx, avx2, popcnt, lzcnt")
#include <bits/stdc++.h>
#include <experimental/random>
using namespace std;
void solve1();
using ll = long long;
using ull = unsigned long long;
using ld = double;
using BIG = __int128_t;
# define int long long
const int MOD = 1e9 + 7;
const int INF = 1e9;
signed main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int qwerty = 1;
// cin >> qwerty;
while (qwerty--) {
solve1();
}
}
void solve1() {
int n, m, k;
cin >> n >> m >> k;
int a, b, c;
cin >> a >> b >> c;
int t;
cin >> t;
vector<pair<int, int>> poses(m);
for (int i = 0; i < m; i++) {
cin >> poses[i].first;
}
for (int i = 0; i < m; i++) {
poses[i].second = (poses[i].first - 1) * b;
}
k -= m;
while (k--) {
m = poses.size();
vector<pair<int, int>> best;
for (int i = 0; i < m - 1; i++) {
if (poses[i + 1].first == poses[i].first + 1) continue;
int can1 = poses[i + 1].first - poses[i].first - 1;
int no_need = min(can1, max(0ll, (t - poses[i].second)) / a);
int next = min(poses[i + 1].first - 1, poses[i].first + no_need + 1);
int can2 = max(0ll, poses[i + 1].first - next - 1);
int dd = poses[i].second + (next - poses[i].first) * c;
int no_need2 = min(can2, max(0ll, (t - dd) / a));
if (dd <= t) {
no_need2++;
}
best.push_back({max(0ll, no_need2), next});
}
sort(best.rbegin(), best.rend());
poses.push_back({best[0].second, -1});
sort(poses.begin(), poses.end());
for (int i = 0; i < poses.size(); i++) {
if (poses[i].second == -1) {
poses[i].second = (poses[i].first - poses[i - 1].first) * c + poses[i - 1].second;
}
}
}
int ans = 0;
m = poses.size();
for (
int i = 0;
i < m;
i++) {
if (poses[i].second <= t) ans++;
}
for (
int i = 0;
i + 1 <
m;
i++) {
int can = poses[i + 1].first - poses[i].first - 1;
int del = (t - poses[i].second) / a;
del = min(del, can);
ans += max(0ll, del);
}
cout << ans - 1;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |