제출 #479784

#제출 시각아이디문제언어결과실행 시간메모리
479784arujbansal로봇 (IOI13_robots)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "robots.h"

using namespace std;

int putaway(int A, int B, int T, vector<int> X, vector<int> Y, vector<int> W, vector<int> S) {
	sort(W.begin(), W.end());
	sort(S.begin(), S.end(), greater<>());

	vector<pair<int, int>> toys(T);
	for (int i = 0; i < T; i++)
		toys[i] = make_pair(W[i], S[i]);

	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());

	int low = 0, high = T, ans = T + 5;
	while (low <= high) {
		int allowed = low + (high - low) / 2;

		priority_queue<int> pq;

		for (int i = 0, j = 0, can_pick = 0; i < A; i++, can_pick += allowed) {
			while (j < T && toys[j].first < W[i])
				pq.push(toys[j++].second);

			while (!pq.empty() && can_pick > 0) {
				pq.pop();
				can_pick--;

			}
		}

		for (int i = 0, can_pick = 0; i < B; i++, can_pick += allowed) {
			while (!pq.empty() && pq.top() < B[i] && can_pick > 0) {
				pq.pop();
				can_pick--;
			}
		}

		if (pq.empty()) {
			high = allowed - 1;
			ans = allowed;
		} else low = allowed + 1;

	}

	return (ans < T + 5 ? ans : -1);
}

컴파일 시 표준 에러 (stderr) 메시지

robots.cpp: In function 'int putaway(int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
robots.cpp:35:38: error: invalid types 'int[int]' for array subscript
   35 |    while (!pq.empty() && pq.top() < B[i] && can_pick > 0) {
      |                                      ^