Submission #43778

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

#define fi first
#define se second

inline int in() {
	int result = 0;
	char ch = getchar_unlocked();
	while (true) {
		if(ch >= '0' && ch <= '9')
			break;
		ch = getchar_unlocked();
	}
	result = ch-'0';
	while(true) {
		ch = getchar_unlocked();
		if (ch < '0' || ch > '9')
			break;
		result = result*10 + (ch - '0');
	}
	return result;
}
inline void out(int x) {
	int rev=x, count = 0;
	if(x == 0) {
putchar_unlocked('0');
putchar_unlocked('\n');
return;
}
	while((rev % 10) == 0) {
++count;
rev /= 10;
} //obtain the count of the number of 0s
	rev = 0;
	while(x != 0) {
rev = rev*10 + x % 10;
x /= 10;
} //store reverse of N in rev
	while(rev != 0) {
putchar_unlocked(rev % 10 + '0');
rev /= 10;
}
	while(count--)
putchar_unlocked('0');
	putchar_unlocked('\n');
}

const int mxN1=5e4, mxN2=1e6;
int a, b, t, x[mxN1], y[mxN1];
pair<int, int> ty[mxN2];
priority_queue<int> pq;

inline bool can(int m) {
	pq = priority_queue<int>();
	for(int i1=0, i2=0; i1<a; ++i1) {
		for(; i2<t&&ty[i2].fi<x[i1]; pq.push(ty[i2++].se));
		for(int j=0; j<m&&!pq.empty(); pq.pop(), ++j);
	}
	for(int i=t-1; i>=0&&ty[i].fi>=(a?x[a-1]:0); pq.push(ty[i--].se));
	for(int i1=b-1; i1>=0&&!(!pq.empty()&&pq.top()>=y[i1]); --i1)
		for(int j=0; j<m&&!pq.empty(); pq.pop(), ++j);
	return pq.empty();
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	a=in(), b=in(), t=in();
	for(int i=0; i<a; ++i)
		x[i]=in();
	sort(x, x+a);
	for(int i=0; i<b; ++i)
		y[i]=in();
	sort(y, y+b);
	for(int i=0; i<t; ++i)
		ty[i].fi=in(), ty[i].se=in();
	sort(ty, ty+t);
	int l=1, r=t+1;
	while(l<=r) {
		int m=(l+r)/2;
		if(can(m))
			r=m-1;
		else
			l=m+1;
	}
	cout << (l>t?-1:l);
}

Compilation message (stderr)

/tmp/cc2nwpNE.o: In function `main':
robots.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccjb0q0f.o:grader.c:(.text.startup+0x0): first defined here
/tmp/ccjb0q0f.o: In function `main':
grader.c:(.text.startup+0x180): undefined reference to `putaway'
collect2: error: ld returned 1 exit status