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 Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
const int N = 3010;
ll n, m, k;
ll B, C, A;
ll s[N];
ll T;
ll cnt(int i, int x)
{
ll rem = T - s[i] * B;
if (rem < 0)
return 0;
ll ans = 0;
Loop (_,0,x+1) {
ll x = rem/A + 1;
ans += x;
rem -= x * C;
if (rem < 0)
break;
}
return min(ans, s[i+1]-s[i]);
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
cin >> n >> m >> k;
cin >> A >> B >> C;
cin >> T;
Loop (i,0,m) {
cin >> s[i];
--s[i];
}
s[m] = n;
ll ans = 0;
priority_queue<tuple<ll,ll,ll>> pq;
Loop (i,0,m) {
ll x = cnt(i, 0);
ll y = cnt(i, 1);
ans += x;
pq.push({y-x, i, 0});
}
Loop (_,0,k-m) {
auto [plus, i, cur] = pq.top();
pq.pop();
ans += plus;
ll x = cnt(i, cur+1);
ll y = cnt(i, cur+2);
pq.push({y-x, i, cur+1});
}
cout << ans-1 << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |