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
using namespace std;
int main()
{
ll N,M,K; cin >> N >> M >> K;
ll A,B,C; cin >> A >> B >> C;
ll T; cin >> T;
vector<ll> nxt(M,-1), stations(M);
for(int i = 0;i<M;++i){
cin >> stations[i];
stations[i]--;
}
for(int i = 0;i<M;++i){
if((T-stations[i]*B) >= 0) nxt[i] = (T-stations[i]*B)/A;
else nxt[i] = -1;
if(i != M-1) nxt[i] = min(nxt[i],stations[i+1]-stations[i]-1);
else nxt[i] = min(0ll,nxt[i]);
//cout << nxt[i] << "\n";
}
for(int i = 0;i<K-M;++i){
ll maxn = -1, pos = -1;
for(int j = 0;j<M-1;++j){
if(T-stations[j]*B-(nxt[j]+1)*C < 0) continue;
ll cnt = (T-stations[j]*B-(nxt[j]+1)*C)/A + nxt[j]+1;
cnt = min(cnt,stations[j+1]-stations[j]-1);
if(cnt > maxn){
maxn = cnt;
pos = j;
}
}
if(maxn != -1){
nxt[pos] = maxn;
//cout << stations[pos] << " " << nxt[pos] << " " << maxn << "\n";
}
}
ll ans = 0;
for(int i = 0;i<M;++i){
ans += nxt[i]+1;
}
cout << ans-1 << "\n";
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... |