# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
698139 | finn__ | City (BOI06_city) | C++17 | 1098 ms | 16856 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
uint64_t n, t, k;
cin >> n >> t >> k;
vector<uint64_t> c(k);
for (uint64_t &x : c)
cin >> x;
auto compare_cost = [&c, &t](pair<uint64_t, uint64_t> const &x, pair<uint64_t, uint64_t> const &y)
{
return t * x.first + c[x.second] > t * y.first + c[y.second];
};
priority_queue<pair<uint64_t, uint64_t>, vector<pair<uint64_t, uint64_t>>, decltype(compare_cost)> q(compare_cost);
q.emplace(0, 0);
uint64_t leftover = n, cost = 0;
while (leftover)
{
auto p = q.top();
q.pop();
while (leftover && (q.empty() || compare_cost(q.top(), p)) && p.second < k)
{
cost += min(leftover, 4 * (p.first + 1)) * (t * p.first + c[p.second]);
leftover -= min(leftover, 4 * (p.first + 1));
p.second++;
if (p.second == 1)
q.emplace(p.first + 1, 0);
}
if (p.second < k)
q.push(p);
}
cout << cost << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |