Submission #846450

# Submission time Handle Problem Language Result Execution time Memory
846450 2023-09-07T14:53:40 Z vjudge1 OGLEDALA (COI15_ogledala) C++17
41 / 100
2490 ms 524288 KB
#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
#define N 300005
using namespace std;
int arr[N];

int32_t main(){
	fast
	int m, n, q;
	cin>>m>>n>>q;
	multiset <pair<int, int> > st; // başlangıç indexi ve uzunluk

	int prev = 0;
	for(int i = 0; i < n; i++) {
		cin>>arr[i];
		st.insert({-(arr[i] - prev - 1), prev + 1});
		prev = arr[i];
	}
	st.insert({-(m - prev), prev + 1});

	int pushed = n;
	int len, l, mid;
	while(q--) {
		int b;
		cin>>b;
		if(b <= n) {
			mid = arr[b - 1];
		}
		while(pushed < b) {
			pair<int, int> it = *(st.begin());
			st.erase(st.begin());
			len = -(it.first), l = it.second;
			mid = l - 1 + (len + 1) / 2;
			st.insert({-(mid - l), l});
			st.insert({-(mid - l + !(len % 2)), mid + 1});
			// cout<<(mid-l)<<" "<<l<<" | "<<(mid - l + !(len % 2))<<" "<<(mid + 1)<<"\n";
			pushed++;
		}
		cout<<mid<<"\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 37 ms 7252 KB Output is correct
4 Correct 37 ms 5772 KB Output is correct
5 Correct 92 ms 22096 KB Output is correct
6 Correct 107 ms 21992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 19092 KB Output is correct
2 Correct 87 ms 19216 KB Output is correct
3 Correct 125 ms 22676 KB Output is correct
4 Correct 115 ms 21320 KB Output is correct
5 Correct 131 ms 22880 KB Output is correct
6 Correct 138 ms 22848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2490 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -