제출 #764961

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

using namespace std;

void debug_out(){cerr << endl;}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
	cout << H << ' ';
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

const int maxn = 1e6 + 10;

int n, a, b, x[maxn], y[maxn], w[maxn], s[maxn];
vector<int> val[maxn];

bool check(int k){
	priority_queue<int> q;
	for (int i = 0; i < a; i++){
		for (auto x: val[i]) q.push(x);
		int tmp = k;
		while(tmp > 0 && !q.empty()){
			q.pop();
			tmp--;
		}
	}
	for (auto x: val[a]) q.push(x);
	for (int i = b-1; ~i; i--){
		if (q.empty()) continue;
		if (q.top() >= y[i]) break;
		int tmp = k;
		while(tmp > 0 && !q.empty()){
			q.pop();
			tmp--;
		}
	}
	return q.empty();
}

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
	n = T;
	a = A;
	b = B;
	for (int i = 0; i < a; i++) x[i] = X[i];
	for (int i = 0; i < b; i++) y[i] = Y[i];
	for (int i = 0; i < n; i++){
		w[i] = W[i];
		s[i] = S[i];
	}
	sort(x, x+a);
	sort(y, y+b);
	for (int i = 0; i < n; i++){
		int idx = upper_bound(x, x + a, w[i]) - x;
		val[idx].push_back(s[i]);
	}
	int l = 0, r = n+1;
	while(l + 1 < r){
		int mid = (l + r) >> 1;
		if (check(mid)) r = mid;
		else l = mid;
	}
	return (r == n+1? -1: r);
}

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

/usr/bin/ld: /tmp/ccpY5G2Q.o: in function `main':
grader.c:(.text.startup+0x1b1): undefined reference to `putaway'
collect2: error: ld returned 1 exit status