Submission #165129

#TimeUsernameProblemLanguageResultExecution timeMemory
165129cbertramSemiexpress (JOI17_semiexpress)C++14
18 / 100
2 ms504 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<string> vs; typedef vector<vb> vvb; typedef vector<vi> vvi; typedef vector<vll> vvll; #define all(x) x.begin(), x.end() #define rep(i,a,b) for(int i = a; i < b; i++) int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll N, M, K; cin >> N; cin >> M; cin >> K; ll A, B, C; cin >> A; cin >> B; cin >> C; ll T; cin >> T; vll S(M+1); rep(m,0,M) cin >> S[m]; rep(m,0,M+1) S[m]--; S[M] = S[M-1]+1; ll sum = 0; priority_queue<pair<ll, pll>> pq; rep(m,0,M) { ll reach = (T-B*S[m])/A; if(T < B*S[m]) break; sum += min(S[m+1]-S[m], 1+reach); if(S[m]+reach+1 < S[m+1] && T >= B*S[m]+C*(reach+1)) pq.push(make_pair(1+(T-B*S[m]-C*(reach+1))/A , make_pair(S[m]+reach+1, m))); } ll k = K-M; while(!pq.empty() && k > 0) { auto top = pq.top(); pq.pop(); sum += min(S[top.second.second+1]-top.second.first, top.first); //cout << "S: " << top.second.first << '\n'; k--; ll nextpos = top.second.first+top.first; if(nextpos < S[top.second.second+1] && T >= B*S[top.second.second]+C*(nextpos-S[top.second.second])) { pq.push(make_pair(min(S[top.second.second+1]-nextpos, 1+(T-B*S[top.second.second]-C*(nextpos-S[top.second.second]))/A), make_pair(nextpos, top.second.second))); } } cout << sum-1 << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...