답안 #13818

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
13818 2015-04-03T04:36:31 Z gs14004 로봇 (IOI13_robots) C++14
컴파일 오류
0 ms 0 KB
#include <cstdio>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int,int> pi;

int n,p,q;

pi a[1000005];
int b[50005], c[50005];

int t[1000005];

bool trial(int x){
    priority_queue<int> pq;
    int bp = 0;
    int cnt = 0;
    for (int i=0; i<n; i++) {
        while(bp < p && b[bp] <= a[i].first){
            int p = x;
            while (p && !pq.empty()) {
                pq.pop();
                p--;
                cnt++;
            }
            bp++;
        }
        pq.push(a[i].second);
    }
    int sz = (int)pq.size();
    for (int i=sz-1; i>=0; i--) {
        t[i] = pq.top();
        pq.pop();
    }
    bp = 0;
    int cp = 0;
    for (int i=0; i<sz; i++) {
        while (bp < q && c[bp] <= t[i]) {
            int p = x;
            while (p && cp < i) {
                cp++;
                cnt++;
            }
        }
    }
    return cnt == n;
}

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){
    p = A, q = B, n = T;
    for (int i=0; i<n; i++) {
        a[i] = pi(W[i],S[i]);
    }
    for (int i=0; i<p; i++) {
        b[i] = X[i];
    }
    for (int i=0; i<q; i++) {
        c[i] = Y[i];
    }
    sort(a,a+n);
    sort(b,b+p);
    sort(c,c+q);
    if(!trial(T)) return -1;
    int s = 0, e = T;
    while (s != e) {
        int m = (s+e)/2;
        if(trial(m)) e = m;
        else s = m+1;
    }
    return s;
}

Compilation message

/tmp/cc3fc62L.o: In function `main':
grader.c:(.text.startup+0x176): undefined reference to `putaway'
collect2: error: ld returned 1 exit status