Submission #964537

# Submission time Handle Problem Language Result Execution time Memory
964537 2024-04-17T05:23:33 Z UmairAhmadMirza Robots (IOI13_robots) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
deque<pair<int,int>> toy,temp;
bool check(int A,int B,int T,int X[], int Y[],int lim){
	toy=temp;
	priority_queue<int> v;
	for (int i = 0; i < A; ++i)
	{
		while(toy.size()){
			if(toy[0].first>=X[i])
				break;
			v.push(toy[0].second);
			toy.pop_front();
		}
		int cnt=0;
		while(v.size() && cnt<lim){
			cnt++;
			v.pop();
		}
	}
	for(auto i:toy)
		v.push(i.second);
	toy.clear();
	stack<int> sz;
	while(v.size()){
		sz.push(v.top());
		v.pop();
	}
	int p=0;
	int cnt=0;
	int i=0;
	while(sz.size() && p<B){
		if(sz.top()>=Y[p]){
			p++;
			cnt=0;
		}
		else if(cnt==lim){
			p++;
			cnt=0;
		}
		else{
			cnt++;
			sz.pop();
		}
	}
	if(sz.size()==0)
		return 1;
	return 0;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){
	int maxX=0,maxY=0;
	for (int i = 0; i < A; ++i)
		maxX=max(maxX,X[i]);
	for (int i = 0; i < B; ++i)
		maxY=max(maxY,Y[i]);
	for (int i = 0; i < T; ++i){
		if(W[i]>=maxX && S[i]>=maxY)
			return -1;
		temp.push_back({W[i],S[i]});
	}
	sort(temp.begin(), temp.end());
	sort(X,X+A);
	sort(Y,Y+B);
	int low=0,high=T;
	while(high-low>1){
		int mid=(low+high)/2;
		if(check(A,B,T,X,Y,mid))
			high=mid;
		else
			low=mid;
	}
	return high;
}

Compilation message

robots.cpp: In function 'bool check(int, int, int, int*, int*, int)':
robots.cpp:31:6: warning: unused variable 'i' [-Wunused-variable]
   31 |  int i=0;
      |      ^
/usr/bin/ld: /tmp/ccAjsyVc.o: in function `main':
grader.c:(.text.startup+0x1b1): undefined reference to `putaway'
collect2: error: ld returned 1 exit status