Submission #805700

#TimeUsernameProblemLanguageResultExecution timeMemory
805700kirakaminski968Semiexpress (JOI17_semiexpress)C++17
0 / 100
0 ms212 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...