Submission #332857

#TimeUsernameProblemLanguageResultExecution timeMemory
332857limabeansSemiexpress (JOI17_semiexpress)C++17
100 / 100
15 ms4600 KiB
#include <bits/stdc++.h> using namespace std; template<typename T> void out(T x) { cout << x << endl; exit(0); } #define watch(x) cout << (#x) << " is " << (x) << endl using ll = long long; ll n,m,k; ll a,b,c; ll t; vector<ll> s; vector<ll> w; ll solve(ll l, ll r) { ll res = 0; ll cnt = 0; ll at = l; ll time = b*l; while (at<r && cnt<=k-m) { if (t-time<0) break; ll dist = (t-time)/a; ll to = min(r,at+dist+1); if (l==at) { res = to-at; } else { w.push_back(to-at); } cnt++; time += (to-at)*c; at = to; } return res; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>m>>k; cin>>a>>b>>c; cin>>t; s.resize(m); for (int i=0; i<m; i++) { cin>>s[i]; --s[i]; } ll res = 0; if (b*s[m-1] <= t) res=1; for (int i=0; i+1<m; i++) { res += solve(s[i],s[i+1]); } sort(w.rbegin(), w.rend()); for (int i=0; i<k-m && i<(int)w.size(); i++) { res += w[i]; } res--; //except station 1 cout<<res<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...