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;
#define pb push_back
#define ll long long
constexpr int MAX = 3069;
ll n, m, k, a, b, c, t;
int s[MAX];
int main()
{
ios :: sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> k >> a >> b >> c >> t;
for (int i = 1; i <= m; ++i)
cin >> s[i];
s[m+1] = (int)n+1;
ll res = 0;
vector<ll> v;
for (int i = 1; i <= m && b * (s[i] - 1) <= t; ++i)
{
ll rem = t - b*(s[i] - 1);
ll prv = min((ll)s[i+1] - 1, s[i] + rem/a);
res += prv - s[i] + 1;
for (int rep = 0; rep < k && prv + 1 < s[i+1]; ++rep)
{
ll tmp = rem - (prv+1 - s[i]) * c;
if (tmp < 0)
break;
ll nxt = min((ll)s[i+1] - 1, prv+1 + tmp/a);
v.pb(nxt - prv);
prv = nxt;
}
}
sort(v.begin(), v.end(), greater<ll>());
for (int i = 0; i < min(k-m, (ll)v.size()); ++i)
res += v[i];
cout << res - 1 << '\n';
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... |