Submission #925208

#TimeUsernameProblemLanguageResultExecution timeMemory
925208niterSemiexpress (JOI17_semiexpress)C++14
18 / 100
1 ms348 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); } } inline void have_ans(){ cout << ans << '\n'; // if(ans != real_ans){ // cerr << "WA : \n"; // cerr << n << ' ' << m << ' ' << k << '\n'; // cerr << A << ' ' << B << ' ' << C << '\n' << T << '\n'; // loop(i,0,m){ // cout << arr[i] << ' '; // } cerr << '\n'; // cerr << "expected : " << real_ans << '\n'; // cerr << "got : " << ans; // exit(1); // } } void solve(){ ans = 0; while(!pq.empty()) pq.pop(); cin >> A >> B >> C >> T; loop(i,0,m){ cin >> arr[i]; } // cin >> real_ans; 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()){ have_ans(); 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.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; } have_ans(); } int main(){ ios::sync_with_stdio(false); cin.tie(0); // freopen("input_checked.txt", "r", stdin); while(cin >> n >> m >> k){ solve(); } // cerr << "AC\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...