Submission #655163

#TimeUsernameProblemLanguageResultExecution timeMemory
655163ParsaSSemiexpress (JOI17_semiexpress)C++14
100 / 100
1 ms464 KiB
// In the name of God #include<bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define mp make_pair typedef long long ll; const int N = 2e5 + 5; int n, m, k; int A, B, C, S[N]; ll T; void solve() { cin >> n >> m >> k; cin >> A >> B >> C; //assert(A > C && C > B); cin >> T; for (int i = 0; i < m; i++) cin >> S[i]; // sort(S, S + m); k -= m; ll ans = -1; multiset<pair<pair<int, ll>, int> > st; for (int i = 0; i < m - 1; i++) { ll L = S[i], R = S[i + 1]; ll need = 1LL * B * (S[i] - 1); if (need > T) break; ll cnt = min(R - L, (T - need) / A + 1); ans += cnt; need += 1LL * C * cnt; if (need > T) continue; //cout << i << ' ' << cnt << ' ' << min(R - (L + cnt), (T - need) / A + 1) << endl; st.insert(mp(mp(-min(R - (L + cnt), (T - need) / A + 1), T - need), R - (L + cnt))); } ans += 1LL * B * (n - 1) <= T; while (!st.empty() && k--) { pair<pair<int, ll>, int> p = *st.begin(); st.erase(st.begin()); ll L = -p.fi.fi, Tp = p.fi.se, len = p.se; ans += L; Tp -= 1LL * C * L; if (Tp < 0) continue; len -= L; L = min((ll)len, 1 + (Tp / A)); if (L > 0) { st.insert(mp(mp(-L, Tp), len)); } } cout << ans << '\n'; } int32_t main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...