版本比较
题解:AT_joi2017ho_b 準急電車 (Semiexpress)
正文
增加 10 行删除 10 行
26 行未改动272829303131323334353637383939404142434445464748484950515252535455565757585959606161626364646566676768696970717226 行未改动
int work(int i, int x, int t) { // 在 s[i]->s[i+1] 中 // 在 x 处下车了 // 用 t 个时间,最远能走几步 // 用 t 个时间,最远能走几步 return min(t / A, a[i + 1] - 1 - x);}
signed main() { cin >> n >> n >> k >> A >> B >> C >> t; k -= n; for (int i = 1; i <= n; ++ i ) cin >> a[i];
priority_queue<tuple<int, int, int, int>> q; for (int i = 1; i < n; ++ i ) if ((a[i] - 1) * B <= t) { int nxt = work(i, a[i], t - (a[i] - 1) * B); int to = work(i, a[i] + nxt + 1, t - (a[i] - 1) * B - (nxt + 1) * C); q.emplace(to, i, a[i] + nxt + 1, (a[i] - 1) * B + (nxt + 1) * C); res += nxt + 1; }
while (q.size()) { auto top = q.top(); q.pop();
int to = get<0>(top); int i = get<1>(top); int pos = get<2>(top); int dis = get<3>(top);
if (dis > t) continue;
res += to + 1;
k -- ; if (!k) break;
q.emplace(work(i, pos + to + 1, t - dis - (to + 1) * C), i, pos + to + 1, dis + (to + 1) * C); }
cout << res + ((a[n] - 1) * B <= t) - 1;
return 0;}```