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<iostream>
#include<queue>
using namespace std;
typedef long long llint;
const int MAXN = 3005;
llint n, m, k, t, a, b, c, lim, sol;
llint s[MAXN], d[MAXN];
priority_queue < pair <llint, int> > pq;
llint val (int ind) {
llint ost = (t - (s[ind]-1)*b - (s[ind+1]-s[ind]-1 - d[ind])*c);
if (ost < c) return 0; return min(d[ind], 1 + (ost - c)/a);
}
int main () {
cin >> n >> m >> k >> a >> b >> c >> t;
for (int i=1; i<=m; i++) {
cin >> s[i];
}
for (int i=m; i>=1; i--) {
if (t >= (s[i]-1) * b) {
lim = i;
break;
}
}
for (int i=1; i<=min(lim, m-1); i++) {
d[i] = max(0LL, (s[i+1]-s[i]-1) - (t-(s[i]-1)*b) / a);
pq.push(make_pair(val(i), i));
}
for (int i=0; i<k-m; i++) {
llint v = pq.top().first;
int ind = pq.top().second;
pq.pop();
d[ind] -= v;
pq.push(make_pair(val(ind), ind));
}
for (int i=1; i<=min(lim, m-1); i++) {
sol += s[i+1] - s[i] - d[i];
}
cout << sol + (lim == m) - 1;
return 0;
}
Compilation message (stderr)
semiexpress.cpp: In function 'llint val(int)':
semiexpress.cpp:16:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if (ost < c) return 0; return min(d[ind], 1 + (ost - c)/a);
^~
semiexpress.cpp:16:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
if (ost < c) return 0; return min(d[ind], 1 + (ost - c)/a);
^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |