Submission #1081124

#TimeUsernameProblemLanguageResultExecution timeMemory
1081124TrentSemiexpress (JOI17_semiexpress)C++17
100 / 100
1 ms460 KiB
#include "bits/stdc++.h" using namespace std; #define forR(i, x) for(int i=0; i<(x); ++i) #define REP(i, a, b) for(int i=(a); i<(b); ++i) #define all(x) x.begin(), x.end() #define boost() cin.sync_with_stdio(0); cin.tie(0) typedef long long ll; typedef vector<int> vi; const int MK = 3010; ll s[MK]; ll fe[MK]; ll a, b, c, t; ll aCheck(ll fs) { // i >= 1: a * i + fs <= t -> i <= (t-fs) / a return (t-fs)/a; } struct interval{ int pe, ne; ll cp; }; ll amtNew(interval i) { ll aCan = s[i.ne] - i.cp; ll from = c * (i.cp - s[i.pe]) + fe[i.pe]; // i >= 0: a * i + from <= t -> i <= (t-from)/a if(t >= from) return min(aCan, (t-from)/a + 1); return 0; } bool operator <(interval p, interval q) { return amtNew(p) < amtNew(q); } signed main() { boost(); int n, m, k; cin >> n >> m >> k; cin >> a >> b >> c; cin >> t; REP(i, 1, m+1) { cin >> s[i]; fe[i] = b * (s[i] - s[1]); } int cnt = k - m; ll tot = 0; REP(i, 2, m+1) if(fe[i] <= t) { ++tot; // cerr << s[i] << '\n'; } priority_queue<interval> ivl; REP(i, 1, m) { if(fe[i] <= t) { ll cr = aCheck(fe[i]); ll ain = s[i+1] - s[i] - 1; ll nCan = min(ain, cr); tot += nCan; // cerr << s[i] + 1 << ' ' << s[i] + nCan << '\n'; if(s[i] + nCan + 1 < s[i+1]) { ivl.push({i, i+1, s[i] + nCan + 1}); } } } forR(j, cnt) if(!ivl.empty()) { interval bes = ivl.top(); ivl.pop(); ll inc = amtNew(bes); if(inc > 0) { // cerr << bes.cp << ' ' << bes.cp + inc - 1 << '\n'; tot += inc; if(bes.cp + inc < s[bes.ne]) { ivl.push({bes.pe, bes.ne, bes.cp + inc}); } } } cout << tot << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...