이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
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 |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |