제출 #648495

#제출 시각아이디문제언어결과실행 시간메모리
648495ymmSemiexpress (JOI17_semiexpress)C++17
100 / 100
11 ms340 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...