Submission #385816

#TimeUsernameProblemLanguageResultExecution timeMemory
385816idontreallyknowSemiexpress (JOI17_semiexpress)C++17
100 / 100
9 ms5484 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template<class A> ostream& operator<<(ostream &cout, vector<A> const &v) {cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";}; template<class A, class B> ostream& operator<<(ostream &cout, const pair<A,B> &x) {return cout << "(" <<x.first << ", " << x.second << ")";}; template <class T> void pv(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) cerr << *i << " "; cerr << "]\n";} void _print() {cerr << "]\n";} template <class T, class... V> void _print(T t, V... v) {cerr << t; if (sizeof...(v)) cerr << ", "; _print(v...);} #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #define fi first #define se second #define SZ(x) (int)((x).size()) #define pii pair<ll,ll> const int mx = 3e3+5; ll n,m,k,a,b,c,t,s[mx]; vector<ll> amt[mx]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> k >> a >> b >> c >> t; k -= m; ll ans = 0; for (int q = 1; q <= m; q++) cin >> s[q]; for (int q = 1; q <= m-1; q++) { ll rem = t-(s[q]-s[1])*b; if (rem < 0) break; ll cur = s[q]; for (int w = 0; w <= k; w++) { if (cur >= s[q+1] || rem < 0) break; ll z = rem/a; ll en = min(cur+z,s[q+1]-1); if (w == 0) ans += (en-cur+1); else amt[q].push_back(en-cur+1); rem -= (en-cur+1)*c; cur = en+1; } } for (int q = 1; q <= m-1; q++) reverse(amt[q].begin(), amt[q].end()); priority_queue<pii> pq; for (int q = 1; q <= m-1; q++) { if (SZ(amt[q])) pq.push({amt[q].back(),q}); } while (k > 0 && SZ(pq)) { pii x = pq.top(); pq.pop(); ans += x.fi; amt[x.se].pop_back(); if (SZ(amt[x.se])) pq.push({amt[x.se].back(),x.se}); k--; } if ((s[m]-s[1])*b <= t) ans++; cout << ans-1 << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...