Submission #94634

#TimeUsernameProblemLanguageResultExecution timeMemory
94634Retro3014Robots (IOI13_robots)C++17
0 / 100
2 ms376 KiB
#include "robots.h"
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

struct S{
	int w, s;
	bool operator <(const S &a)const{
		return w<a.w;
	}
};

vector<S> v;
vector<int> x, y;
priority_queue<int> pq;

bool chk(int k){
	while(!pq.empty())	pq.pop();
	int j=0, t;
	for(int i=0; i<v.size(); i++){
		while(j<x.size() && x[j]<=v[i].w){
			t = k;
			while(t-- && !pq.empty())	pq.pop();
			j++;
		}
		pq.push(v[i].s);
	}
	for(int i=y.size()-1; i>=0; i--){
		t = k;
		while(t-- && !pq.empty()){
			if(pq.top()>=y[i])	return false;
			pq.pop();
		}
	}
	return pq.empty();
}

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
  	for(int i=0; i<A; i++)	x.push_back(X[i]);
  	for(int i=0; i<B; i++)	y.push_back(Y[i]);
  	for(int i=0; i<T; i++)	v.push_back({W[i], S[i]});
	sort(x.begin(), x.end()); sort(y.begin(), y.end()); sort(v.begin(), v.end());
	int s = 0, e = 1000000, m;
	while(s<e){
		m = (s+e)/2;
		if(chk(m))	e = m;
		else	s = m+1;
	}
	if(chk(s))	return s;
	return -1;
}

Compilation message (stderr)

robots.cpp: In function 'bool chk(int)':
robots.cpp:23:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<v.size(); i++){
               ~^~~~~~~~~
robots.cpp:24:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(j<x.size() && x[j]<=v[i].w){
         ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...