Submission #925209

#TimeUsernameProblemLanguageResultExecution timeMemory
925209niterSemiexpress (JOI17_semiexpress)C++14
100 / 100
1 ms604 KiB
#include <bits/stdc++.h> #define loop(i,a,b) for(int i = (a); i < (b); i ++) #define pb push_back #define BAE(x) x.begin(), x.end() #define unisort(x) sort(BAE(x)); x.resize(unique(BAE(x)) - x.begin()) using namespace std; typedef long long ll; const int mxn = 3005; int n, m, k, ans, real_ans; ll A, B, C, T; int arr[mxn]; struct range{ ll base, ed, nxt_base, nxt_ed, get, sz; }; struct cmp{ bool operator()(range x, range y){ return x.get < y.get; } }; priority_queue<range, vector<range>, cmp> pq; inline void build(int l, int r, ll base_cost){ if(l > r) return; if(base_cost > T) return; range tmp; // the cost of the (l-1) th station tmp.base = base_cost; tmp.sz = r - l + 1; // the first station whose distance is greater than T. tmp.ed = min((T - base_cost) / A + 1, tmp.sz + 1); ans += tmp.ed - 1; tmp.nxt_base = tmp.base + tmp.ed * C; if(tmp.ed > tmp.sz || tmp.nxt_base > T){ return; } tmp.nxt_ed = min(tmp.ed + ((T - tmp.nxt_base) / A + 1), tmp.sz + 1); tmp.get = tmp.nxt_ed - tmp.ed; if(tmp.get > 0){ pq.push(tmp); } } void solve(){ cin >> n >> m >> k; cin >> A >> B >> C >> T; loop(i,0,m){ cin >> arr[i]; } loop(i,1,m){ if(B * (arr[i] - 1) <= T) ans += 1; build(arr[i-1] + 1, arr[i] - 1, B * (arr[i-1] - 1)); } if(pq.empty()){ cout << ans << '\n'; return; } loop(build_count,0,k-m){ range now = pq.top(); pq.pop(); ans += now.get; if(now.nxt_ed != now.sz + 1){ now.base = now.nxt_base; now.sz -= now.ed; now.ed = min((T - now.base) / A + 1, now.sz + 1); if(now.ed <= now.sz && now.base + C <= T){ now.nxt_base = now.base + now.ed * C; now.nxt_ed = min(now.ed + ((T - now.nxt_base) / A + 1), now.sz + 1); now.get = now.nxt_ed - now.ed; if(now.get > 0) pq.push(now); } } if(pq.empty()) break; } cout << ans << '\n'; } int main(){ ios::sync_with_stdio(false); cin.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...