이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 = 0, pos = -1;
for(int j = 0;j<M-1;++j){
if((T-stations[j]*B-(nxt[j]+1)*C) < 0) continue;
ll cur = nxt[j]+1;
ll cnt = (T-stations[j]*B-cur*C)/A+cur;
cnt = min(cnt,stations[j+1]-stations[j]-1);
if(cnt-cur+1 > maxn){
maxn = cnt-cur+1;
pos = j;
}
}
if(maxn > 0){
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... |