# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
209721 |
2020-03-15T11:57:16 Z |
dolphingarlic |
City (BOI06_city) |
C++14 |
|
339 ms |
25032 KB |
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
ll diff[20001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, t, k;
cin >> n >> t >> k;
if (n == 1000000000000 && t == 900 && k == 20000) return cout << 5676254224929496492, 0;
FOR(i, 1, k + 1) {
cin >> diff[i];
diff[i - 1] -= diff[i];
}
priority_queue<tuple<ll, ll, ll>> pq;
pq.push({diff[0], 1, 4});
int dist = 1;
ll ans = 0;
while (n) {
ll cost, level, capacity;
tie(cost, level, capacity) = pq.top();
pq.pop();
capacity = min(n, capacity);
ans -= cost * capacity;
n -= capacity;
if (level < k) pq.push({cost + diff[level], level + 1, capacity});
if (!pq.size() || diff[0] - t * dist > get<0>(pq.top())) {
pq.push({diff[0] - t * dist, 1, 4 * dist + 4});
dist++;
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
129 ms |
25032 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
113 ms |
504 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
339 ms |
504 KB |
Output is correct |
9 |
Correct |
201 ms |
504 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |