Submission #371212

# Submission time Handle Problem Language Result Execution time Memory
371212 2021-02-26T06:14:44 Z Plasmatic Semiexpress (JOI17_semiexpress) C++14
0 / 100
1 ms 620 KB
// ./joi-2017-final-p2----semiexpress.yml
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const ll INF = 0x3f3f3f3f, LLINF = 0x3f3f3f3f3f3f3f3f;

const int MM = 3011;
int N, M, K;
ll A, B, C, T,
   gain[MM][MM], ptr[MM], S[MM];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> N >> M >> K >> A >> B >> C >> T;
    for (int i = 0; i < M; i++) cin >> S[i];
    S[M] = N+1;
    K -= M;

    // calculate "gain" amount
    for (int i = 0; i < M; i++) {
        ll cur = S[i]-1;
        for (int j = 0; j <= K; j++) {
            ll init = (S[i]-1)*B + (cur+1-S[i])*C;
            if (init > T) break;
            ll nxt = min(cur+1 + (T-init) / A, S[i+1]-1);
            gain[i][j] = nxt - cur;
            cur = nxt;
        }
    }

    // greedy
    priority_queue<pair<ll, int>> pq;
    ll ans = -1; // subtract station 1
    for (int i = 0; i < M; i++) {
        ans += gain[i][0];
        if (K > 0)
            pq.emplace(gain[i][1], i);
    }

    for (int i = 0; i < K; i++) {
        auto t = pq.top(); pq.pop();
        ans += t.first;
        ptr[t.second]++;
        if (ptr[t.second] < K)
            pq.emplace(gain[i][ptr[t.second]+1], t.second);
    }
    cout << ans << '\n';

    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 620 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 620 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 620 KB Output isn't correct
4 Halted 0 ms 0 KB -