CSES - Datatähti 2023 alku - Results
Submission details
Task:Sadonkorjuu
Sender:Luc
Submission time:2022-11-11 13:35:42 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:31:31: error: invalid cast from type '__gnu_pbds::tree_order_statistics_node_update<__gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<int, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<int, long unsigned int, std::allocator<char> >*, int, int*, const int*, int&, const int&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<int, long unsigned int, std::allocator<char> >*, int, int*, const int*, int&, const int&, true, std::allocator<char> >, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<int, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<int, long unsigned int, std::allocator<char> >*, int, int*, const int*, int&, const int&,...

Code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
 
int main(){
	freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);
		
	int n, m, te, sz, tt, et;
	scanf("%d %d", &n, &m);
	multiset<int> ms;
	indexed_set s;
	while(n){
		scanf("%d", &te);
		//t.push_back(te);
		s.insert(te);
		ms.insert(te);
		n--;
	}
	//sort(t.begin(), t.end());
	sz = s.size();
	while(m){
		scanf("%d", &te);
		tt = s.order_of_key(te);
		if(tt<sz && 0<tt){
			if(te<(int)s.find_by_order(tt)) tt-=1;
			et=s.find_by_order(tt));
			printf("%d\n", et);
			ms.erase(ms.find(et));
			if(!ms.count(et)){
				s.erase(et);
				sz--;
			}
		}else printf("%d\n", -1);
		//cout << *it<<"\n"; 
		/*while(*it!=-1){
			*it=*(it-1);
			it--;
		}*/
		m--;
	}
}