제출 #940009

#제출 시각아이디문제언어결과실행 시간메모리
940009qwe1rt1yuiop1Semiexpress (JOI17_semiexpress)C++14
100 / 100
12 ms11612 KiB
#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<vector<int>> add(m - 1, vector<int>(k + 1, 0));
    for (int i = 0; i < m - 1; ++i)
    {
        int lft = t - c * v[i], cur = 0;
        for (int j = 0; j <= k && lft >= 0; ++j)
        {
            add[i][j] = 1 + lft / a;
            add[i][j] = min(add[i][j], v[i + 1] - v[i] - cur);
            lft -= b * add[i][j];
            cur += add[i][j];
        }
    }

    priority_queue<pii> pq;
    int ans = 0;
    for (int i = 0; i < m - 1; ++i)
    {
        ans += add[i][0];
        if (1 < k + 1)
            pq.emplace(add[i][1], i * 1000000 + 1);
    }
    
    while (k--)
    {
        auto [val, id] = pq.top();
        pq.pop();
        ans += val;
        int i = id / 1000000;
        id %= 1000000;
        pq.emplace(add[i][id + 1], i * 1000000 + id + 1);
    }

    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;
}

컴파일 시 표준 에러 (stderr) 메시지

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