제출 #59394

#제출 시각아이디문제언어결과실행 시간메모리
59394spencercompton로봇 (IOI13_robots)C++17
90 / 100
1022 ms66560 KiB
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) {
	sort(x,x+a);
	sort(y,y+b);
	map<int, int> m;
	set<int> ss;
	int inf = 2000000001;
	for(int i = b-1; i>=0; i--){
		m[y[i]] = i;
		ss.insert(y[i]);
	}
	m[inf] = b;
	ss.insert(inf);

	vector<pair<int, int> > li;
	for(int i = 0; i<t; i++){
		li.push_back(make_pair(w[i],s[i]));
	}
	sort(li.begin(),li.end());
	int above[t];
	for(int i = 0; i<t; i++){
		auto it = ss.upper_bound(li[i].second);
		above[i] = m[*it];
		//mit
	}
	int low = 1;
	int high = t+1;
	while(low<high){
		int mid = (low+high)/2;
		priority_queue<int> pq;
		int point = 0;
		for(int i = 0; i<a; i++){
			while(point<t && li[point].first<x[i]){
				pq.push(above[point++]);
			}
			for(int j = 0; j<mid && pq.size()>0; j++){
				pq.pop();
			}
		}
		while(point<t){
			pq.push(above[point++]);
		}
		int cnt[b+1];
		for(int i = 0; i<=b; i++){
			cnt[i] = 0;
		}
		while(pq.size()>0){
			cnt[pq.top()]++;
			pq.pop();
		}
		long long maxi = 0LL;
		bool ok = true;
		int sum = 0;
		for(int i = b; i>=0 && ok; i--){
			sum += cnt[i];
			ok &= sum <= maxi;
			maxi += mid;
		}
		if(ok){
			high = mid;
		}
		else{
			low = mid+1;
		}
	}
    return (low<=t?low:-1);
}
#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...