# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
698075 |
2023-02-12T08:24:15 Z |
finn__ |
City (BOI06_city) |
C++17 |
|
1000 ms |
12784 KB |
#include <bits/stdc++.h>
using namespace std;
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), curr_floor(1, 0);
for (uint64_t &x : c)
cin >> x;
auto compare_cost = [&c, &curr_floor, &t](uint64_t const &x, uint64_t const &y)
{
return t * x + c[curr_floor[x]] > t * y + c[curr_floor[y]];
};
priority_queue<uint64_t, vector<uint64_t>, decltype(compare_cost)> q(compare_cost);
q.push(0);
uint64_t leftover = n, cost = 0;
while (leftover)
{
uint64_t const x = q.top();
q.pop();
cost += min(leftover, 4 * (x + 1)) * (t * x + c[curr_floor[x]]);
leftover -= min(leftover, 4 * (x + 1));
curr_floor[x]++;
if (curr_floor[x] < k)
q.push(x);
if (curr_floor[x] == 1)
{
curr_floor.push_back(0);
q.push(x + 1);
}
}
cout << cost << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
148 ms |
12784 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
93 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
856 KB |
Output is correct |
6 |
Correct |
1 ms |
600 KB |
Output is correct |
7 |
Execution timed out |
1089 ms |
528 KB |
Time limit exceeded |
8 |
Correct |
347 ms |
384 KB |
Output is correct |
9 |
Correct |
199 ms |
392 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |