답안 #618819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
618819 2022-08-02T07:43:29 Z HappyPacMan OGLEDALA (COI15_ogledala) C++14
41 / 100
2563 ms 524288 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

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

	int M,N,Q;
	cin >> M >> N >> Q;
	vector<int> vec;
	vec.push_back(0);
	for(int i=0;i<N;i++){
		int Ai;
		cin >> Ai;
		vec.push_back(Ai);
	}
	vec.push_back(M+1);
	priority_queue<pair<int,int> > pq;
	for(int i=1;i<vec.size();i++){
		pq.emplace(vec[i]-vec[i-1],-vec[i-1]);
	}
	int curr = N+1;
	while(Q--){
		int Bi;
		cin >> Bi;
		if(Bi <= N){
			cout << vec[Bi] << "\n";
		}else{
			while(curr < Bi){
				auto [u,v] = pq.top();
				pq.pop();
				int lw = u/2;
				int hg = (u+1)/2;
				pq.emplace(lw,v);
				pq.emplace(hg,v-lw);
				curr++;
			}
			auto [u,v] = pq.top();
			cout << -v+u/2 << "\n";
		}
	}
}

Compilation message

ogledala.cpp: In function 'int32_t main()':
ogledala.cpp:20:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(int i=1;i<vec.size();i++){
      |              ~^~~~~~~~~~~
ogledala.cpp:31:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |     auto [u,v] = pq.top();
      |          ^
ogledala.cpp:39:9: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   39 |    auto [u,v] = pq.top();
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 25 ms 2888 KB Output is correct
4 Correct 25 ms 2916 KB Output is correct
5 Correct 56 ms 9976 KB Output is correct
6 Correct 60 ms 9980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 8616 KB Output is correct
2 Correct 40 ms 8640 KB Output is correct
3 Correct 66 ms 10472 KB Output is correct
4 Correct 61 ms 10584 KB Output is correct
5 Correct 65 ms 10748 KB Output is correct
6 Correct 72 ms 10676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2563 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -