제출 #593263

#제출 시각아이디문제언어결과실행 시간메모리
593263promaRobots (IOI13_robots)C++17
28 / 100
182 ms5960 KiB
#include "robots.h"
#include <bits/stdc++.h>

using namespace std;

bool check(int a, int t, int w[], int x[], int m) {
    int i, j = 0, cnt = 0;
    for (i = 0; i < t;) {
        if (j >= a) return false;
        if (w[i] < x[j]) {
            cnt ++;
            i ++;
        }
        else {
            j ++;
            cnt = 0;
        }
        if (cnt == m) {
            j ++;
            cnt = 0;
        }
    }
    if (i != t) return false;
    return true;
}

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
    if (A + B == 2 and T == 2) {
        sort(X, X + A);
        sort(Y, Y + B);
        if (!A) {
            if (S[0] < Y[0] and S[1] < Y[1]) return 1;
            if (S[0] < Y[1] and S[1] < Y[1]) return 2;
            return -1;
        }
        else if (!B) {
            if (W[0] < X[0] and W[1] < X[1]) return 1;
            if (W[0] < X[1] and W[1] < X[1]) return 2;
            return -1;
        }
        else {
            if ((W[0] < X[0] and S[1] < Y[0]) or (S[0] < Y[0] and W[1] < X[0])) return 1;
            if ((W[0] < X[0] and W[1] < X[0]) or (S[0] < Y[0] and S[1] < Y[0])) return 2;
            return -1;
        }
    }

    sort(W, W + T);
    sort(X, X + A);
    if (W[T-1] > X[A-1]) return -1;
    int l = 1, r = T, ans = T;
    while (l <= r) {
        int m = (l + r) / 2;
        if (check(A, T, W, X, m)) {
            ans = m;
            r = m - 1;
        }
        else {
            l = m + 1;
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...