Submission #1079581

# Submission time Handle Problem Language Result Execution time Memory
1079581 2024-08-28T18:00:35 Z Staheos City (BOI06_city) C++14
50 / 100
1000 ms 26816 KB
#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, pair<long long, long long>>, vector<pair<long long, pair<long long, long long>>>, std::greater<pair<long long, pair<long long, long long>>>>();
	long long s = 0;
	long long l = 0;

	for (int i = 0; i < 1000000; i++)
	{
		q.push(pair<long long, pair<long long, long long>>(c[0] + (i + 1 - 1) * t, pair<long long, long long>(i, 0))); // i, j
		//for (int j = 0; j < k; j++)
		//{
		//	// -1, bo |x| + |y| - 1
		//	//q.push(pair<long long, pair<long long, long long>>(c[j] + (i + 1 - 1) * t, pair<long long, long long>(j, (i + 1) * 4)));
		//	q.push(pair<long long, pair<long long, long long>>(c[j] + (i + 1 - 1) * t, pair<long long, long long>(i, j))); // i, j
		//}
	}

	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, q.top().second);
		s = s + q.top().first * min(n - l, (q.top().second.first + 1) * 4);
		//l = l + min(n - l, (long long) q.top().second);
		l = l + min(n - l, (q.top().second.first + 1) * 4);
		
		q.push(pair<long long, pair<long long, long long>>(c[q.top().second.second + 1] + (q.top().second.first + 1 - 1) * t, pair<long long, long long>(q.top().second.first, q.top().second.second + 1)));
		q.pop();
	}

	cout << s << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 26816 KB Output is correct
2 Correct 73 ms 26536 KB Output is correct
3 Execution timed out 1031 ms 26560 KB Time limit exceeded
4 Correct 136 ms 25532 KB Output is correct
5 Execution timed out 1068 ms 25796 KB Time limit exceeded
6 Execution timed out 1069 ms 25796 KB Time limit exceeded
7 Execution timed out 1016 ms 25792 KB Time limit exceeded
8 Correct 340 ms 26292 KB Output is correct
9 Correct 214 ms 26052 KB Output is correct
10 Incorrect 21 ms 25064 KB Output isn't correct