Submission #875620

# Submission time Handle Problem Language Result Execution time Memory
875620 2023-11-20T08:13:55 Z vjudge1 Semiexpress (JOI17_semiexpress) C++17
0 / 100
0 ms 348 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]);
        }
        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], 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]], i);
        }
        cout << res - 1;
}
# 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 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -