Submission #1116070

#TimeUsernameProblemLanguageResultExecution timeMemory
1116070crafticatRobots (IOI13_robots)C++17
Compilation error
0 ms0 KiB

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define F0R(i, n) for (ll i = 0; i < n;i++)
#define FOR(i,j, n) for (ll i = j; i < n;i++)
template<typename T>
using V = vector<T>;
using vi = V<ll>;
using vb = V<bool>;
using pi = pair<ll, ll>;
#define f first
#define s second
#define all(x) begin(x), end(x)
constexpr ll INF = 1e11;

V<pi> scan(V<pi> arr, vi xL, ll k) {
    sort(all(arr));
    reverse(all(arr));

    multiset<pi> elms;
    for (auto x : xL) {
        elms.emplace(x, k);
    }
    V<pi> results;

    for (auto [a,b] : arr) {
        auto it = elms.upper_bound({b, INF});
        if (it == elms.end()) {
            results.emplace_back(a,b);
            continue;
        }

        auto [x, am] = *it;
        elms.erase(it); am--;
        if (am > 0) elms.emplace(x, am);
    }

    return results;
}

bool ok(vi x, vi y, V<pi> elms, ll k) {
    for (auto &[a,b] : elms) swap(a,b );
    elms = scan(elms, x, k);
    for (auto &[a,b] : elms) swap(a,b );
    elms = scan(elms, y, k);
    return elms.empty();
}

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
    ll l = 0, r = INF;
    vi x(A), y(B);
    V<pi> elms(T);
    F0R(i, A) {
        x[i] = X[i];
    }
    F0R(i, B) {
        y[i] = Y[i];
    }
    F0R(i, T) {
        elms[i] = {W[i], S[i]};
    }

    while (r > l) {
        ll mid = l + (r - l) / 2;

        if (!ok(x, y, elms, mid)) {
            l = mid + 1;
        } else {
            r = mid;
        }
    }

    if (l >= INF) return -1;
    return l;
}

#if DEBUG

#define MAX_A 50000
#define MAX_B 50000
#define MAX_T 500000

static int X[MAX_A];
static int Y[MAX_B];
static int W[MAX_T];
static int S[MAX_T];

int main() {
    int A, B, T, i;

	assert(scanf("%d", &A) == 1);
	assert(scanf("%d", &B) == 1);
	assert(scanf("%d", &T) == 1);

	for (i = 0; i < A; i++)
		assert(scanf("%d", &X[i]) == 1);
	for (i = 0; i < B; i++)
        assert(scanf("%d", &Y[i]) == 1);
	for (i = 0; i < T; i++)
        assert(scanf("%d%d", &W[i], &S[i]) == 2);

    int answer = putaway(A, B, T, X, Y, W, S);

	printf("%d\n", answer);

	return 0;
}
#endif

Compilation message (stderr)

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