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"
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
*/
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
using ll = long long;
const int mod = 1e9+7;
void solve(int tc) {
ll n, m, k, a, b, c, t;
cin >> n >> m >> k;
cin >> a >> b >> c;
cin >> t;
vector<ll> v(m);
for (auto &x : v) cin >> x;
ll ans = ((n-1) * b <= t);
priority_queue<int> pq;
for (int i = 0; i < m-1; ++i) {
ll tm = (v[i] - 1) * b;
if (tm > t) break;
ll cur = (t - tm) / a;
ll mxr = min(v[i+1]-1, v[i] + cur);
ans += mxr - v[i] + 1;
if (!i) --ans;
for (int j = 0; j < k and mxr < v[i+1]-1; ++j) {
ll tm2 = tm + (mxr + 1 - v[i]) * c;
if (tm2 > t) break;
ll cur2 = (t - tm2) / a;
ll mxr2 = min(v[i+1]-1, mxr+1+cur2);
pq.push(mxr2-mxr);
mxr = mxr2;
}
}
for (int i = 0; i < k-m and !pq.empty(); ++i) {
ans += pq.top();
pq.pop();
}
cout << ans << '\n';
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int tc = 1;
//cin >> tc;
for (int i = 1; i <= tc; ++i) solve(i);
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... |