Submission #1204476

#TimeUsernameProblemLanguageResultExecution timeMemory
1204476PlayVoltzRobots (IOI13_robots)C++20
100 / 100
1391 ms24432 KiB
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

signed putaway(signed x, signed y, signed n, signed X[], signed Y[], signed w[], signed s[]){
	vector<pii> toys(n);
	for (int i=0; i<n; ++i)toys[i]=mp(w[i], s[i]);
	vector<int> weak(x), small(y);
	for (int i=0; i<x; ++i)weak[i]=X[i];
	for (int i=0; i<y; ++i)small[i]=Y[i];
	sort(weak.begin(), weak.end());
	sort(small.begin(), small.end());
	sort(toys.begin(), toys.end());
	int low=-1, high=n+1;
	while (low+1<high){
		int mid = (low+high)/2, p=0;
		priority_queue<int> pq;
		priority_queue<int, vector<int>, greater<int> > pq2;
		for (auto c:weak){
			while (p<n&&toys[p].fi<c)pq.push(toys[p].se), ++p;
			int t=mid;
			while (!pq.empty()&&t--)pq.pop();
		}
		while (!pq.empty())pq2.push(pq.top()), pq.pop();
		while (p<n)pq2.push(toys[p].se), ++p;
		for (auto c:small){
			int t=mid;
			while (!pq2.empty()&&pq2.top()<c&&t--)pq2.pop();
		}
		if (pq2.empty())high=mid;
		else low=mid;
	}
	return (high==n+1?-1:high);
}

#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...