Submission #67566

#TimeUsernameProblemLanguageResultExecution timeMemory
67566thebesRobots (IOI13_robots)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int,int> pii;
const int MN = 1e6+6;
pair<int,int> wts[MN];
priority_queue<int> q;
int N, M, T, i;
vector<int> a, b;
bool check(int m){
	while(q.size()) q.pop();
	int i=0, j = 0;
	for(i=0,j=0;i<N;i++){
		while(j<T&&wts[j].first<a[i]) q.push(wts[j++].second);
		for(int k=0;k<m&&q.size();k++) q.pop();
	}
	for(;j<T;j++) q.push(wts[j].second);
	for(int k=b.size()-1;k>=0;k--){
		for(int i=0;i<m&&q.size()&&q.top()<b[k];i++) q.pop();
	}
	return q.empty();
}
int putaway(int A,int B,int t,int *X,int *Y,int *W,int *S){
	N = A, M = B, T = t;
	for(int i=0;i<T;i++)
		wts[i] = {W[i],S[i]};
	for(int i=0;i<N;i++)
		a.push_back(X[i]);
	for(int i=0;i<M;i++)
		b.push_back(Y[i]);
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(wts,wts+T,[](pii i,pii j){return i.first<j.first;});
	int lo = 1, hi = T+1;
	while(lo<hi){
		int m = lo+hi>>1;
		if(check(m)) hi=m;
		else lo=m+1;
	}
	return(hi==T+1)?-1:hi;
}

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:36:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m = lo+hi>>1;
           ~~^~~
/tmp/cc47qSbJ.o: In function `main':
grader.c:(.text.startup+0x17e): undefined reference to `putaway'
collect2: error: ld returned 1 exit status