Submission #897357

# Submission time Handle Problem Language Result Execution time Memory
897357 2024-01-03T02:14:03 Z box Semiexpress (JOI17_semiexpress) C++17
100 / 100
1 ms 468 KB
#include <bits/stdc++.h>
using namespace std;
    
typedef long long LL;
    
int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int n, m, k; cin >> n >> m >> k;
    LL a, b, c; cin >> a >> b >> c;
    long long t; cin >> t;
    vector<LL> s(m), p(m - 1); for (LL& x : s) cin >> x;
    priority_queue<pair<LL, int>> pq;
    LL ans = b * (n - 1) <= t ? 0 : -1;
    for (int i = 0; i < m - 1; i++) {
        if (b * (s[i] - 1) > t) continue;
        LL u = min(s[i + 1] - 1, s[i] + (t - b * (s[i] - 1)) / a);
        ans += u - s[i] + 1;
        p[i] = u + 1;
        if (p[i] < s[i + 1] && b * (s[i] - 1) + c * (p[i] - s[i]) <= t)
            pq.push({min(s[i + 1] - 1, p[i] + (t - b * (s[i] - 1) - c * (p[i] - s[i])) / a) - p[i] + 1, i});
    }
    for (int it = 0; it < k - m; it++) {
        if (pq.empty()) break;
        auto [v, i] = pq.top(); pq.pop();
        ans += v, p[i] += v;
        if (p[i] < s[i + 1] && b * (s[i] - 1) + c * (p[i] - s[i]) <= t)
            pq.push({min(s[i + 1] - 1, p[i] + (t - b * (s[i] - 1) - c * (p[i] - s[i])) / a) - p[i] + 1, i});
    }
    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct