#include <iostream>
#include <queue>
using namespace std;
int main()
{
long long n, t, k;
cin >> n >> t >> k;
long long* c = new long long[k];
for (int i = 0; i < k; i++)
{
cin >> c[i];
}
auto q = priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, std::greater<pair<long long, long long>>>();
long long s = 0;
long long l = 0;
for (int i = 0; i < 1000; i++)
{
for (int j = 0; j < k; j++)
{
// -1, bo |x| + |y| - 1
q.push(pair<long long, long long>(c[j] + (i + 1 - 1) * t, (i + 1) * 4));
}
}
while (l < n)
{
//cout << "DODANI: " << min(n - l, (long long)q.top().second) << ' ' << q.top().first * min(n - l, (long long)q.top().second) << '\n';
s = s + q.top().first * min(n - l, (long long)q.top().second);
l = l + min(n - l, (long long) q.top().second);
q.pop();
}
cout << s << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
246 ms |
344 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
349 ms |
66296 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
432 KB |
Output isn't correct |
7 |
Runtime error |
519 ms |
524288 KB |
Execution killed with signal 9 |
8 |
Incorrect |
834 ms |
66164 KB |
Output isn't correct |
9 |
Incorrect |
224 ms |
33240 KB |
Output isn't correct |
10 |
Correct |
2 ms |
1492 KB |
Output is correct |