Submission #80890

#TimeUsernameProblemLanguageResultExecution timeMemory
80890Dat160601Semiexpress (JOI17_semiexpress)C++17
100 / 100
3 ms1336 KiB
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define fi first #define se second int n, m, k, s[3007]; long long a, b, c, t, ans = 0; priority_queue < pair < int , pair < int, int > > > pr; int main(){ ios_base::sync_with_stdio(0); cin >> n >> m >> k; cin >> a >> b >> c >> t; k -= m; for(int i = 1; i <= m; i++){ cin >> s[i]; } for(int i = 1; i < m; i++){ long long cur = 1LL * (s[i] - 1) * b; if(cur > t) break; long long reach = min(1LL * s[i + 1] - 1, (s[i] + (t - cur) / a)); ans += reach - s[i] + 1; if(reach != s[i + 1] - 1){ reach++; int sv = reach; cur += 1LL * (reach - s[i]) * c; //cout << reach << " " << cur << endl; if(cur > t) continue; reach = min(1LL * s[i + 1] - 1, (reach + (t - cur) / a)); pr.push(mp(reach - sv + 1, mp(i, reach + 1))); } } if(1LL * (n - 1) * b <= t) ans++; while(!pr.empty()){ if(k == 0) break; k--; ans += pr.top().fi; int id = pr.top().se.fi; int pos = pr.top().se.se; pr.pop(); if(pos >= s[id + 1]) continue; long long cur = 1LL * (s[id] - 1) * b + 1LL * (pos - s[id]) * c; if(cur > t) continue; long long reach = min(1LL * s[id + 1] - 1, (pos + (t - cur) / a)); pr.push(mp(reach - pos + 1, mp(id, reach + 1))); } cout << ans - 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...