Submission #823930

#TimeUsernameProblemLanguageResultExecution timeMemory
823930AmirElarbiSemiexpress (JOI17_semiexpress)C++14
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #define INF 1e9 #define ve vector #define vi ve<int> #define ii pair<int,int> #define vii ve<ii> #define pb push_back #define fi first #define se second #define ll long long using namespace __gnu_pbds; using namespace std; const int nax = 2e5+5; const int kax = 25+5; const int MOD = 1e9+7; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n,m,k; cin >> n >> m >> k; ll a,b,c,t; cin >> a >> b >> c >> t; priority_queue< pair<ll,pair<ll,int>> > pq; ll ans = 0; ve<ll> s(m+1); s[m] = n+1; for (int i = 0; i < m; ++i) { cin >> s[i]; } for (int i = 0; i < m; ++i) { ll trav = (s[i]-1)*1ll*b; if(t < trav) break; ll mx = min(s[i+1], s[i]+(t-trav)/a+1); ans += mx-s[i]; ll tse = trav + (mx-s[i]) * 1ll * c; if(t < tse) continue; ll mxse = min(s[i+1], mx+(t-tse)/a+1); if(mxse > mx) pq.push({mxse-mx, {mxse,i}}); } for (int aa = 0; aa < k-m; ++aa) { if(pq.empty()) break; pair<ll,pair<ll,int>> cur = pq.top(); pq.pop(); ll i = cur.se.se; ans += cur.fi; ll trav = (s[i]-1)*1ll*b + (cur.se.fi-s[i])*1ll*c; if(t < trav) continue; ll mx = min(s[i+1], cur.se.fi+(t-trav)/a+1); if(mx > cur.se.fi && mx != s[i+1]) pq.push({mx-cur.se.fi, {mx,i}}); } cout << ans-1 << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...