제출 #945050

#제출 시각아이디문제언어결과실행 시간메모리
945050oblantisRobots (IOI13_robots)C++17
100 / 100
1304 ms25900 KiB
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int inf = INT_MAX;
const int mod = 1e9+7;
const int maxn = 5002;
#include "robots.h"

int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) {
	int l = 0, r = t + 1;
	vt<pii> v;
	sort(y , y + b);
	for(int i = 0; i < a; i++){
		v.pb({x[i] - 1, inf});
	}
	for(int i = 0; i < t; i++){
		v.pb({w[i], s[i]});
	}
	sort(all(v));
	while(l + 1 < r){
		int mid = l + (r - l) / 2;
		priority_queue<int> pq;
		bool ok = 1;
		for(int i = 0; i < t + a; i++){
			if(v[i].ss == inf){
				for(int j = 0; j < mid && !pq.empty(); j++)pq.pop();
			}
			else {
				pq.push(v[i].ss);
			}
		}
		for(int i = b - 1; !pq.empty() && i >= 0; i--){
			if(pq.top() >= y[i]){
				break;
			}
			for(int j = 0; !pq.empty() && j < mid; j++)pq.pop();
		}
		if(!pq.empty())ok = 0;
		if(ok)r = mid;
		else l = mid;
	}
	if(r > t)return -1;
	return r;
}

//int main() {
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
	//int a, b, t;
	//cin >> a >> b >> t;
	//int x[a], y[b], w[t], s[t];
	//for(int i = 0; i < a; i++)cin >> x[i];
	//for(int i = 0; i < b; i++)cin >> y[i];
	//for(int i = 0; i < t; i++)cin >> w[i] >> s[i];
	//cout << putaway(a, b, t, x, y, w, s);

	//return 0;
//}

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