# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
730085 | thimote75 | City (BOI06_city) | C++14 | 1079 ms | 16820 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define num long long
#define vn vector<num>
#define ph pair<num, pair<int, int>>
#define sp priority_queue<ph, vector<ph>, greater<ph>>
#define stage second.second
#define dist second.first
#define cost first
vn costs;
num N, T;
int K;
sp current;
ph next (ph &x) {
int s = x.stage + 1;
int d = x.dist;
num c = d * T + costs[s];
return { c, { d, s } };
}
ph create (int d) {
return { d * T + costs[0], { d, 0 } };
}
num count (int d) {
return 4 * d + 4;
}
int main () {
cin >> N >> T >> K;
costs.resize(K);
for (int i = 0; i < K; i ++) cin >> costs[i];
current.push(create(0));
num ans = 0;
int i = 0;
while (N > 0) {
ph res = current.top();
current.pop();
if (res.stage + 1 != K)
current.push(next(res));
if (res.stage == 0)
current.push(create(res.dist + 1));
num size = min(count(res.dist), N);
N -= size;
ans += size * res.cost;
}
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |