#include <bits/stdc++.h>
using namespace std;
#define num long long
#define vn vector<num>
#define ph pair<num, pair<int, int>>
#define sp set<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.insert(create(0));
num ans = 0;
int i = 0;
while (N > 0) {
ph res = *(current.begin());
current.erase(res);
if (res.stage + 1 != K)
current.insert(next(res));
if (res.stage == 0)
current.insert(create(res.dist + 1));
num size = min(count(res.dist), N);
N -= size;
ans += size * res.cost;
i ++;
if (i == 5)
break ;
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
7 |
Incorrect |
7 ms |
596 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |