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;
priority_queue<pair<long long, pair<long long, long long> > > pq;
long long s[3005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, m, k, a, b, c, t, ans=-1;
cin >> n >> m >> k >> a >> b >> c >> t;
for (long long i=1; i<=m; i++)
cin >> s[i];
for (long long i=1; i<m; i++)
{
if (b*(s[i]-1)>t)
break;
long long x=min(s[i+1], (t-b*(s[i]-1)+a*(s[i]+1))/a);
long long y=min(s[i+1], (t-b*(s[i]-1)-c*(x-s[i])+a*(x+1))/a);
ans+=x-s[i];
if (x<y)
pq.push({y-x, {i, y}});
}
if (b*(n-1)<=t)
ans++;
for (long long i=m; i<k; i++)
{
if (pq.empty())
break;
ans+=pq.top().first;
long long ind=pq.top().second.first;
long long x=pq.top().second.second;
long long y=min(s[ind+1], (t-b*(s[ind]-1)-c*(x-s[ind])+a*(x+1))/a);
pq.pop();
if (x<y)
pq.push({y-x, {ind, y}});
}
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... |