Submission #116185

#TimeUsernameProblemLanguageResultExecution timeMemory
116185nvmdavaRobots (IOI13_robots)C++17
76 / 100
3023 ms36072 KiB
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;

vector<pair<int, int>> toy;
vector<int> w, s;

multiset<int> in;

bool pos(int t){
	in.clear();
	int now = 0;
	for(int i = 0; i < w.size(); i++){
		while(now < toy.size() && toy[now].first < w[i]){
			in.insert(toy[now].second);
			now++;
		}
		for(int j = 0; j < t; j++){
			if(in.empty()) break;
			in.erase(--in.end());
		}
	}
	
	for(; now < toy.size(); now++)
		in.insert(toy[now].second);
		
	
	
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < t; j++){
			if(in.empty()) return 1;
			if(*in.begin() >= s[i]) break;
			in.erase(in.begin());
		}
	}
	if(in.empty()) return 1;
	return 0;
}

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
	for(int i = 0; i < T; i++)
		toy.push_back({W[i], S[i]});
	
	for(int i = 0; i < A; i++)
		w.push_back(X[i]);
		
	for(int i = 0; i < B; i++)
		s.push_back(Y[i]);
		
	sort(toy.begin(), toy.end());
	sort(w.begin(), w.end());
	sort(s.begin(), s.end());
	
	int l = 0, r = 1000001;
	int m;
	
	while(l != r){
		m = (l + r) >> 1;
		if(pos(m)) r = m;
		else l = m + 1;
	}
	if(r == 1000001) return -1;
	return r;
}

Compilation message (stderr)

robots.cpp: In function 'bool pos(int)':
robots.cpp:13:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < w.size(); i++){
                 ~~^~~~~~~~~~
robots.cpp:14:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(now < toy.size() && toy[now].first < w[i]){
         ~~~~^~~~~~~~~~~~
robots.cpp:24:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(; now < toy.size(); now++)
        ~~~~^~~~~~~~~~~~
robots.cpp:29:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < s.size(); i++){
                 ~~^~~~~~~~~~
#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...