제출 #386625

#제출 시각아이디문제언어결과실행 시간메모리
386625milleniumEeee로봇 (IOI13_robots)C++17
28 / 100
3070 ms38680 KiB
#include <bits/stdc++.h>
#include "robots.h"
//#include "grader.cpp"
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(), s.end()
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
using namespace std;
 
 
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
	int max_x = 0;
	for (int i = 0; i < A; i++) {
		chkmax(max_x, X[i]);
	}
	int max_y = 0;
	for (int i = 0; i < B; i++) {
		chkmax(max_y, Y[i]);
	}
	for (int i = 0; i < T; i++) {
		if (W[i] < max_x) {
			continue;
		}
		else if (S[i] < max_y) {
			continue;
		}
		else {
			return -1;
		}
	}
	if (A + B == 2 && T == 2) {
		auto can = [&](pair<int, char> robot, int pos) {
			if (robot.sc == 'A') {
				return W[pos] < robot.fr;
			} else {
				return S[pos] < robot.fr;
			}
		};
		vector <pair<int, char>> vec;
		for (int i = 0; i < A; i++) {
			vec.pb(mk(X[i], 'A'));
		}
		for (int i = 0; i < B; i++) {
			vec.pb(mk(Y[i], 'B'));
		}
		if (can(vec[0], 0) && can(vec[1], 1)) {
			return 1;
		}
		if (can(vec[1], 0) && can(vec[0], 1)) {
			return 1;
		}
		return 2;
	}
	multiset <int> toy;
	for (int i = 0; i < T; i++) {
		toy.insert(W[i]);
	}
	int ans = 0;
	while (!toy.empty()) {
		for (int i = 0; i < A; i++) {
			if (toy.empty()) {
				break;
			}
			int x = X[i];
			auto it = toy.lower_bound(x);
			if (it != toy.begin()) {
				it--;
				toy.erase(it);
			}
		}
		ans++;
	}
	return ans;
}
#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...