Submission #17220

# Submission time Handle Problem Language Result Execution time Memory
17220 2015-11-08T11:00:19 Z erdemkiraz Robots (IOI13_robots) C++
0 / 100
3 ms 21648 KB
#include <bits/stdc++.h>

using namespace std;

#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)
typedef long long ll;
typedef pair < int, int > ii;

const int inf = 1e9 + 333;
const ll linf = 1e18 + inf;

#include "robots.h"

const int N = 1e6 + 5;

int n;
int A, B;
int X[N], Y[N];
ii a[N];
vector < int > v;

bool f(int x) {
	int ptr = 0;
	for(int i = 0; i < B; i++) {
		int rem = x;
		while(ptr < n and rem and a[ptr].second <= Y[i]) {
			ptr++;
			rem--;
		}
		if(ptr == n)
			return 1;
	}
	v.clear();
	for(int i = ptr; i < n; i++)
		v.push_back(a[i].first);
	sort(v.begin(), v.end());
	ptr = 0;
	for(int i = 0; i < A; i++) {
		int rem = x;
		while(ptr < v.size() and rem and v[ptr] <= X[i]) {
			ptr++;
			rem--;
		}
		if(ptr == v.size())
			return 1;
	}
	return 0;
}

int putaway(int A, int B, int n, int X[], int Y[], int W[], int S[]) {
	:: n = n;
	:: A = A;
	:: B = B;
	sort(X, X + A);
	sort(Y, Y + B);
	for(int i = 0; i < A; i++)
		:: X[i] = X[i];
	for(int i = 0; i < B; i++)
		:: Y[i] = Y[i];
	for(int i = 0; i < n; i++) {
		a[i] = ii(W[i], S[i]);
	}
	sort(a, a + n);
	for(int i = 0; i < n; i++)
		swap(a[i].first, a[i].second);
	if(!f(n))
		return -1;
	int l = 1, r = n;
	while(l < r) {
		int m = l + r >> 1;
		if(f(m))
			r = m;
		else
			l = m + 1;
	}
	return l;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 21648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 21648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 21648 KB Output is correct
2 Incorrect 3 ms 21648 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 21648 KB Output is correct
2 Incorrect 0 ms 21648 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 21648 KB Output is correct
2 Incorrect 0 ms 21648 KB Output isn't correct
3 Halted 0 ms 0 KB -