이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ' ' << x << '\n'
#define endl '\n'
using namespace std;
const int M = 1e9 + 7;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int N, M, K;
cin >> N >> M >> K;
K -= M;
ll vA, vB, vC;
cin >> vA >> vB >> vC;
ll limit;
cin >> limit;
vector<ll> exprs(M);
for (auto& n: exprs) cin >> n, --n;
priority_queue<piii, vector<piii>, less<piii>> pq;
ll ans = -1;
for (int i = 0; i < M - 1; i++) {
ll tNow = limit - vB * exprs[i];
if (tNow < 0) break;
ans++;
ll nxtA = min(tNow / vA + exprs[i], exprs[i + 1] - 1);
ans += nxtA - exprs[i];
ll xC = (tNow - (nxtA + 1 - exprs[i]) * vC < 0 ? nxtA : nxtA + 1);
ll tC = tNow - (xC - exprs[i]) * vC;
ll possible = min(xC + tC / vA, exprs[i + 1] - 1);
if (possible - nxtA <= 0) continue;
pq.push({possible - nxtA, make_pair(xC, tC)});
}
while (pq.size() && K) {
auto [dx, xt] = pq.top();
auto& [x, t] = xt;
pq.pop();
K--;
ans += dx;
ll nxtExp = *upper_bound(exprs.begin(), exprs.end(), x);
ll nxtA = x + t / vA;
ll xC = (t - (nxtA - x + 1) * vC < 0 ? nxtA : nxtA + 1);
ll tC = t - (xC - x) * vC;
ll possible = min(xC + tC / vA, nxtExp - 1);
if (possible - nxtA == 0) continue;
pq.push({possible - nxtA, make_pair(xC, tC)});
}
if (vB * exprs.back() <= limit) ans++;
cout << ans << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:51:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
51 | auto [dx, xt] = pq.top();
| ^
semiexpress.cpp:52:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
52 | auto& [x, t] = xt;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |