This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
int main(){
ll n; cin >> n;
ll m; cin >> m;
ll k; cin >> k;
ll a, b, c; cin >> a >> b >> c;
ll t; cin >> t;
ll s[m + 1];
ll f[m + 1];
ll ans = 0;
for(int i = 1; i <= m; i++)
cin >> s[i];
for(int i = 1; i <= m; i++){
if(i == m){
continue;
}
ll x = (s[i] - 1) * b;
if(x > t) f[i] = s[i];
else{
ll v = t - x;
v /= a;
v++;
f[i] = s[i] + v;
}
f[i] = min(f[i], s[i + 1]);
ans += f[i] - s[i];
}
if(s[m] * b - b <= t) ans++;
k -= m;
while(k--){
ll mx, mxi = -1;
mx = 0;
for(int i = 1; i < m; i++){
ll val = s[i] * b - b;
val += (f[i] - s[i]) * c;
if(val > t)
continue;
ll u = t - val;
ll cnt = u / a;
cnt++;
cnt = min(cnt, s[i + 1] - f[i]);
if(cnt > mx)
mx = cnt, mxi = i;
}
ans += mx;
if(mx){
ll val = s[mxi] * b - b;
val += (f[mxi] - s[mxi]) * c;
ll u = t - val;
u /= a;
u++;
u = min(u, s[mxi + 1] - f[mxi]);
f[mxi] += u;
}
}
cout << ans - 1;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |