Submission #908784

#TimeUsernameProblemLanguageResultExecution timeMemory
908784AlphaMale06Semiexpress (JOI17_semiexpress)C++14
100 / 100
11 ms4824 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define int long long


void solve(){
	int n, m, k, a, b, c, t;
	cin >> n >> m >> k >> a >> b >> c >> t;
	vector<int> A(m);
	for(int i=0; i< m; i++)cin >> A[i];
	vector<int> gain;
	int cnt=k-m;
	int ans=0;
	for(int i=0; i< m-1; i++){
		int price=(A[i]-1)*b, st=A[i], nxt=A[i+1];
		if(price>t)break;
		int reach=st+(t-price)/a;
		if(reach>=nxt-1){
			ans+=nxt-st;
			continue;
		}
		else ans+=reach-st+1;
		price+=(reach-st+1)*c;
		st=reach+1;
		for(int j=0; j< cnt; j++){
			if(price>t)break;
			reach=st+(t-price)/a;
			if(reach>=nxt-1){
				gain.pb(nxt-st);
				break;
			}
			else{
				gain.pb(reach-st+1);
			}
			price+=(reach-st+1)*c;
			st=reach+1;
		}
	}	
	sort(all(gain));
	reverse(all(gain));
	for(int i=0; i< min(cnt, (int)gain.size()); i++){
		ans+=max(0ll, gain[i]);
	}
	if((n-1)*b<=t)ans++;
	cout << max(0ll,ans-1) << '\n';
}


signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...