Submission #163419

#TimeUsernameProblemLanguageResultExecution timeMemory
163419iefnah06Semiexpress (JOI17_semiexpress)C++11
100 / 100
4 ms508 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAXM = 3010; const int MAXK = 3010; ll N; int M, K; ll A, B, C; ll T; ll S[MAXM]; ll pos[MAXM]; // covers [l, r) ll go(ll x, ll l, ll m) { ll r = (T - x * (B - C) - l * (C - A) + B) / A + 1; r = max(r, l); r = min(r, m); return r; } ll go(int ind) { return go(S[ind], pos[ind], S[ind+1]); } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> N >> M >> K; cin >> A >> B >> C; cin >> T; for (int i = 0; i < M; i++) { cin >> S[i]; } ll ans = 0; priority_queue<pair<ll, int>> cnds; // {length, index} for (int i = 0; i < M-1; i++) { pos[i] = S[i]; pos[i] = go(i); ans += pos[i] - S[i]; cnds.emplace(go(i) - pos[i], i); } for (int t = 0; t < K - M; t++) { ll l; int ind; tie(l, ind) = cnds.top(); cnds.pop(); ans += l; pos[ind] += l; cnds.emplace(go(ind) - pos[ind], ind); } if (B * (N-1) > T) ans--; cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...