Submission #875622

# Submission time Handle Problem Language Result Execution time Memory
875622 2023-11-20T08:23:40 Z vjudge1 Semiexpress (JOI17_semiexpress) C++17
100 / 100
7 ms 5980 KB
// https://oj.uz/problem/view/JOI17_semiexpress

#include <bits/stdc++.h>
using namespace std;

int32_t main() {
        ios_base::sync_with_stdio(0);
        cin.tie(0);

        int n, m, k;
        cin >> n >> m >> k;
        int a, b, c;
        cin >> a >> b >> c;
        int64_t t;
        cin >> t;
        vector<int> s(m);
        for (int i = 0; i < m; i++) cin >> s[i], s[i]--;
        s.emplace_back(n);
        k -= m;
        vector<vector<int>> add(m, vector<int>(k + 1));
        for (int i = 0; i < m; i++) {
                int64_t cur_time = 1ll * s[i] * b;
                int64_t cur_pos = s[i];
                int j = 0;
                while (cur_time <= t && cur_pos < s[i + 1] && j <= k) {
                        int64_t time_left = t - cur_time;
                        int64_t more = time_left / a;
                        cur_pos += more;
                        cur_pos = min<int64_t>(cur_pos, s[i + 1] - 1);
                        add[i][j] = cur_pos - s[i] + 1;
                        j++;
                        cur_pos++;
                        cur_time = 1ll * s[i] * b + 1ll * (cur_pos - s[i]) * c;
                }
        }
        for (int i = 0; i < m; i++) {
                for (int j = 0; j < k; j++) add[i][j + 1] = max(add[i][j], add[i][j + 1]);
        }
        for (int i = 0; i <= k; i++) add[0][i]--;
        vector<int> cur(m, 1);
        priority_queue<pair<int, int>> pq;
        int res = 0;
        for (int i = 0; i < m; i++) res += add[i][0];
        if (k > 0) {
                for (int i = 0; i < m; i++) pq.emplace(add[i][1] - add[i][0], i);
        }
        int remain = k;
        while (pq.size() && remain > 0) {
                auto [v, i] = pq.top();
                pq.pop();
                remain--;
                res += add[i][cur[i]] - add[i][cur[i] - 1];
                cur[i]++;
                if (cur[i] > k) continue;
                pq.emplace(add[i][cur[i]] - add[i][cur[i] - 1], i);
        }
        cout << res;
}
# 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 1 ms 348 KB Output is correct
4 Correct 0 ms 452 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 1 ms 348 KB Output is correct
4 Correct 0 ms 452 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 1 ms 460 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 1 ms 420 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 1 ms 348 KB Output is correct
4 Correct 0 ms 452 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 1 ms 460 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 1 ms 420 KB Output is correct
19 Correct 2 ms 2908 KB Output is correct
20 Correct 4 ms 5980 KB Output is correct
21 Correct 0 ms 464 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 7 ms 4700 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 356 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 3 ms 1628 KB Output is correct
30 Correct 2 ms 1116 KB Output is correct