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>
#define int long long
using namespace std;
using pii = pair<int, int>;
void solve()
{
int n, m, k, a, b, c, t;
cin >> n >> m >> k >> a >> c >> b >> t;
k -= m;
vector<int> v(m);
for (auto &i : v)
cin >> i, --i;
vector<int> lft(m - 1), cur(m - 1, 0);
priority_queue<pii> pq;
for (int i = 0; i < m - 1; ++i)
{
lft[i] = t - c * v[i];
if (lft[i] >= 0)
{
int add = 1 + lft[i] / a;
add = min(add, v[i + 1] - v[i] - cur[i]);
lft[i] -= b * add;
cur[i] += add;
if (k > 0)
{
add = 1 + lft[i] / a;
add = min(add, v[i + 1] - v[i] - cur[i]);
pq.emplace(add, i);
}
}
}
while (k--)
{
auto [add, i] = pq.top();
pq.pop();
if (lft[i] >= 0)
{
lft[i] -= b * add;
cur[i] += add;
add = 1 + lft[i] / a;
add = min(add, v[i + 1] - v[i] - cur[i]);
pq.emplace(add, i);
}
}
int ans = accumulate(cur.begin(), cur.end(), 0LL);
if (c * v.back() > t)
--ans;
cout << ans << '\n';
}
/*
10 3 5
10 3 5
30
1 6 10
10 3 5
10 3 5
25
1 6 10
90 10 12
100000 1000 10000
10000
1
10 20 30 40 50 60 70 80 90
*/
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}
Compilation message (stderr)
semiexpress.cpp: In function 'void solve()':
semiexpress.cpp:37:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
37 | auto [add, i] = pq.top();
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |