# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
209721 | dolphingarlic | City (BOI06_city) | C++14 | 339 ms | 25032 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|---|---|---|---|
Fetching results... |