Submission #846237

# Submission time Handle Problem Language Result Execution time Memory
846237 2023-09-07T12:46:04 Z vjudge1 OGLEDALA (COI15_ogledala) C++17
0 / 100
2518 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
const int N = 3e5 + 5, MOD = 1e9 + 7;

map<ll, ll> ans;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n, m, asd;
	cin >> m >> n >> asd;

	vector<ll> v;
	v.push_back(0);

	priority_queue<array<ll, 3>> q;

	for(int i = 0; i < n; i++)
	{
		ll x;
		cin >> x;

		v.push_back(x);

		ll l = x - v[i] - 1;

		if(l != 0)
		{
			q.push({l, -(v[i] + 1), -(x - 1)});
		}
	}


	ll l = (m + 1) - v[n] - 1;
	if(l != 0)
	{
		q.push({l, -(v[n] + 1), -((m + 1) - 1)});
	}

	for(ll i = n + 1; i <= m; i++)
	{
		auto cur = q.top();
		q.pop();

		ll l = -cur[1], r = -cur[2];
		ll mid = (l + r) / 2;

		ans[i] = mid;

		ll length = (mid - 1) - l + 1;
		if(length > 0)
		{
			q.push({length, -l, -(mid - 1)});
		}
		length = r - (mid + 1) + 1;
		if(length > 0)
		{
			q.push({length, -(mid + 1), -r});
		}
	}

	while(asd--)
	{
		ll x;
		cin >> x;

		cout << ans[x] << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2518 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2453 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -