# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
698077 |
2023-02-12T08:31:27 Z |
finn__ |
City (BOI06_city) |
C++17 |
|
1000 ms |
16840 KB |
#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 const [x, f] = q.top();
q.pop();
cost += min(leftover, 4 * (x + 1)) * (t * x + c[f]);
leftover -= min(leftover, 4 * (x + 1));
if (f + 1 < k)
q.emplace(x, f + 1);
if (!f)
q.emplace(x + 1, 0);
}
cout << cost << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
152 ms |
16840 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
83 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Execution timed out |
1087 ms |
652 KB |
Time limit exceeded |
8 |
Correct |
291 ms |
376 KB |
Output is correct |
9 |
Correct |
170 ms |
360 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |