이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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+5;
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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |