Submission #1181078

#TimeUsernameProblemLanguageResultExecution timeMemory
1181078Paz15Semiexpress (JOI17_semiexpress)C++20
100 / 100
15 ms11588 KiB
//fast
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(n) for(int i = 0 ; i<n ; i++)
#define all(x) x.begin(),x.end()
#define pb push_back

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m,k;
	cin >> n >> m >> k;
	ll a,b,c;
	cin >> a >> b >> c;
	ll t;
	cin >> t;
	ll s[m];
	rep(m) cin >> s[i];
	k-=m;
	ll res[m-1][k+2];
	ll w = 0;
	priority_queue<pair<ll,pair<int,int>>> q;
	ll xd = 0;
	rep(m-1){
		ll odl = s[i+1]-s[i];
		ll base = xd;
		for (int j = 0 ; j<=k ; j++){
			ll ile = max(0LL,(t-base+a)/a);
			ile = min(ile,odl);
			odl-=ile;
			base+=c*ile;
			res[i][j] = ile;
		}
		xd+=(s[i+1]-s[i])*b;
		res[i][k+1] = 0;
		w+=res[i][0];
		q.push({res[i][1],{i,1}});
	}
	if (xd<=t) w++;
	while (k--){
		ll x = q.top().first;
		auto ind = q.top().second;
		q.pop();
		q.push({res[ind.first][ind.second+1],{ind.first,ind.second+1}});
		w+=x;
	}
	cout << w-1 << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...