Submission #940014

# Submission time Handle Problem Language Result Execution time Memory
940014 2024-03-07T03:54:10 Z qwe1rt1yuiop1 Semiexpress (JOI17_semiexpress) C++14
100 / 100
1 ms 600 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
using pii = pair<int, int>;

void solve()
{
    int n, m, k, a, b, c, t;
    cin >> n >> m >> k >> a >> c >> b >> t;
    k -= m;
    vector<int> v(m);
    for (auto &i : v)
        cin >> i, --i;

    vector<int> lft(m - 1), cur(m - 1, 0);
    priority_queue<pii> pq;
    for (int i = 0; i < m - 1; ++i)
    {
        lft[i] = t - c * v[i];
        if (lft[i] >= 0)
        {
            int add = 1 + lft[i] / a;
            add = min(add, v[i + 1] - v[i] - cur[i]);
            lft[i] -= b * add;
            cur[i] += add;
            if (k > 0)
            {
                add = 1 + lft[i] / a;
                add = min(add, v[i + 1] - v[i] - cur[i]);
                pq.emplace(add, i);
            }
        }
    }

    while (k--)
    {
        auto [add, i] = pq.top();
        pq.pop();
        if (lft[i] >= 0)
        {
            lft[i] -= b * add;
            cur[i] += add;

            add = 1 + lft[i] / a;
            add = min(add, v[i + 1] - v[i] - cur[i]);
            pq.emplace(add, i);
        }
    }

    int ans = accumulate(cur.begin(), cur.end(), 0LL);
    if (c * v.back() > t)
        --ans;
    cout << ans << '\n';
}

/*
10 3 5
10 3 5
30
1 6 10

10 3 5
10 3 5
25
1 6 10

90 10 12
100000 1000 10000
10000
1
10 20 30 40 50 60 70 80 90
 */

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}

Compilation message

semiexpress.cpp: In function 'void solve()':
semiexpress.cpp:37:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |         auto [add, i] = pq.top();
      |              ^
# 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 348 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 348 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 1 ms 348 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 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 348 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 1 ms 348 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 600 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 372 KB Output is correct
30 Correct 0 ms 348 KB Output is correct