#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int inf = 2e18,N = 5e5+1,MOD = 1e9+7;
void solve() {
int n,m,k;
cin >> n >> m >> k;
int a,b,c;
cin >> a >> b >> c;
int t;
cin >> t;
vi x(m+2,inf);
x[m+1] = n+1;
vi lst(m+1,-1);
for (int i=1;i<=m;i++) cin >> x[i];
int ans = 0;
for (int i=1;i<=m;i++) {
if ((x[i]-1)*b > t) continue;
int golast = min(x[i+1]-x[i]-1,(t-b*(x[i]-1))/a);
lst[i] = x[i]+golast;
ans+=golast+1;
}
k-=m;
for (int i=1;i<=k;i++) {
int mx = 0;
for (int city = 1;city <= m;city++) {
if (lst[city] == -1) continue;
if (lst[city]+1 == x[city+1]) continue;
int cost = b*(x[city]-1)+c*(lst[city]+1-x[city]);
if (t-cost < 0) continue;
int expand = min(x[city+1]-lst[city]-1,(t-cost)/a+1);
mx = max(mx,expand);
}
for (int city = 1;city <= m;city++) {
if (lst[city] == -1) continue;
if (lst[city]+1 == x[city+1]) continue;
int cost = b*(x[city]-1)+c*(lst[city]+1-x[city]);
if (t-cost < 0) continue;
int expand = min(x[city+1]-lst[city]-1,(t-cost)/a+1);
if (expand == mx) {
lst[city]+=expand;
ans+=expand;
break;
}
}
}
cout << ans-1 << '\n';
}
int32_t main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifdef Dodi
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int t = 1;
//cin >> t;
while (t --> 0) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |