이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |