Submission #685190

#TimeUsernameProblemLanguageResultExecution timeMemory
685190coffee5427Semiexpress (JOI17_semiexpress)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> #define int long long #define pii pair<int, int> #define pb push_back #define mk make_pair #define F first #define S second #define ALL(x) x.begin(), x.end() using namespace std; using PQ = priority_queue<int, vector<int>, greater<int>>; const int INF = 2e18; const int maxn = 3e5 + 5; const int M = 1e9 + 7; int n, m, k; int Wa, Wb, Wc; int T, ans; priority_queue <pii, vector<pii>, greater<>> pq; map<int, int> mp; void init () { cin >> n >> m >> k; k = k - m; cin >> Wa >> Wb >> Wc; int x; cin >> T; for (int i = 1; i <= m; i++) { cin >> x; pq.push ({x, min (Wa, Wb) * (x - 1)}); mp[x]++; } } int get (int w) { return (T - w) / Wa; } void solve () { while (pq.size ()) { auto [u, w] = pq.top (); pq.pop (); //cout << pq.size () << "\n"; //cout << "u:" << u << ",w:" << w << "\n"; if (w <= T) ans++; //cout << "u:" << u << ",add:++\n"; else continue; if (mp[u] && pq.size ()) { auto [nxt, nxtW] = pq.top (); pq.pop (); nxtW = min ({nxtW, w + min (Wb, Wa) * (nxt - u)}); pq.push ({nxt, nxtW}); } if (pq.size ()) { if (u + get (w) + 1 < pq.top ().F) { if (k) { pq.push ({u + get (w) + 1, w + min (Wc, Wa) * (get (w) + 1)}); ans += get (w); //cout << "u:" << u << ",add:" << get (w) << "\n"; k--; } else { auto [nxt, nxtW] = pq.top (); pq.pop (); nxtW = min ({nxtW, w + Wc * (nxt - u), w + Wa * (nxt - u)}); pq.push ({nxt, nxtW}); ans += get (w); //cout << "u:" << u << ",add:" << get (w) << "\n"; } } else { auto [nxt, nxtW] = pq.top (); pq.pop (); nxtW = min ({nxtW, w + Wc * (nxt - u), w + Wa * (nxt - u)}); pq.push ({nxt, nxtW}); ans += pq.top ().F - u - 1; //cout << "u:" << u << ",add:" << pq.top ().F - u - 1 << "\n"; } } else ans += min (n - u, get (w)), cout << "u:" << u << ",add:" << min (n - u, get (w)) << "\n"; } cout << ans - 1<< "\n"; } signed main() { // ios::sync_with_stdio(0); // cin.tie(0); int t = 1; //cin >> t; while (t--) { init(); solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...