Submission #310473

#TimeUsernameProblemLanguageResultExecution timeMemory
310473talant117408Robots (IOI13_robots)C++17
Compilation error
0 ms0 KiB
#include "robots.h"
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair <ll, ll> pii;
 
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) (int)(v).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX_A 50005
#define MAX_B 50005
#define MAX_T 500005

int x[MAX_A], y[MAX_B], a, b, t;
pii toys[MAX_T];

bool check(int m){
    priority_queue <int> K;
    int i, tt;
    for(i = 0, tt = 0; i <= a; i++){
        for(;tt < t && toys[tt].first < x[i]; tt++)
            K.push(toys[tt].second);
        if(i != a)
            for(int j = 0; j < m && (!K.empty()); j++)
                K.pop();
    }
    
    for(i = b-1; i >= 0 && (K.empty() || K.top() < y[i]); i--){
        for(int j = 0; j < m && !K.empty(); j++) K.pop();
    }
    
    return K.empty();
}

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
    
    a = A; b = B;
    t = T;
    copy(X, X+a, x);
    copy(Y, Y+b, y);
    x[a] = 2e9;
    for(int i = 0; i < t; i++)
        toys[i] = {W[i], S[i]};
        
    sort(x, x+a);
    sort(y, y+b);
    sort(toys, toys+t);
    
    int l = 1, r = t;
    while(l < r){
        int mid = (l+r) >> 1;
        if(check(mid)) r = mid;
        else l = mid+1;
    }
    if(!check(l)) return -1;
    return l;
}

int main() {
    int A, B, T, i;
    
    static int X[MAX_A];
    static int Y[MAX_B];
    static int W[MAX_T];
    static int S[MAX_T];

	cin >> A >> B >> T;

	for (i = 0; i < A; i++) 
        cin >> X[i];
	for (i = 0; i < B; i++)
        cin >> Y[i];
	for (i = 0; i < T; i++)
        cin >> W[i] >> S[i];
    
	int answer = putaway(A, B, T, X, Y, W, S);

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

	return 0;
}

Compilation message (stderr)

/tmp/ccC5M0bt.o: In function `main':
robots.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccRhuqAy.o:grader.c:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status