Submission #995268

#TimeUsernameProblemLanguageResultExecution timeMemory
995268gmroh06Semiexpress (JOI17_semiexpress)C++14
100 / 100
1 ms600 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

const ll INF = 1e16;

ll n, m, k, a, b, c, t, ans;
vector<ll> s, tim, p;
priority_queue<pll> pq;

ll cal(ll x) {
    if (tim[x] > t) {
        return 0;
    } else {
        return min((t - tim[x]) / a + 1, s[x + 1] - p[x]);
    }
}

int main() {
    fastio();

    cin >> n >> m >> k >> a >> b >> c >> t;

    s.resize(m + 1);
    tim.resize(m);
    p.resize(m);

    for (ll i = 0; i < m; i++) {
        cin >> s[i];
        s[i]--;
    }

    s[m] = n, k -= m;

    for (ll i = 0; i < m; i++) {
        tim[i] = b * s[i];
        p[i] = s[i];
    }

    for (ll i = 0; i < m; i++) {
        ll x = max(cal(i), 0LL);

        if (x) {
            p[i] += x;
            tim[i] += x * c;
            ans += x;

            pq.emplace(cal(i), i);
        }
    }

    while (k-- and !pq.empty()) {
        auto [x, idx] = pq.top();
        pq.pop();

        x = max(x, 0LL);

        if (x) {
            p[idx] += x;
            tim[idx] += x * c;
            ans += x;

            pq.emplace(cal(idx), idx);
        } else {
            break;
        }
    }

    cout << ans - 1;

    return 0;
}

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:62:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   62 |         auto [x, idx] = pq.top();
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...