이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#include "robots.h"
vector <pi> toys;
int n;
int weak[50010];
int small[50010];
int now,nos;
int query(int x) {
priority_queue <int> pq;
int cur = 0;
for (int i = 0;i<now;i++) {
while (cur < n and toys[cur].f < weak[i]) {
cur++;
pq.push(toys[cur].s);
}
for (int xd = 0; xd < x; xd++) {
if (pq.empty()) break;
pq.pop();
}
}
while (cur < n) {
pq.push(toys[cur].s);
cur++;
}
for (int i = nos-1;i>=0;i--) {
if (pq.empty()) return 1;
else if (pq.top() >= small[i]) return 0;
for (int xd = 0; xd < x; xd++) {
if (pq.empty() or pq.top() >= small[i]) break;
pq.pop();
}
}
if (pq.empty()) return 1;
else return 0;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
n = T; now = A; nos = B;
for (int i =0;i<A;i++) weak[i] = X[i];
for (int i =0;i<B;i++) small[i] = Y[i];
sort(weak,weak+A);
sort(small,small+B);
for (int i =0;i<n;i++) {
toys.push_back(pi(W[i],S[i]));
}
sort(toys.begin(),toys.end());
int high = T+1;
int low = 0;
while (high - low > 1) {
int mid = (high+low)/2;
//cout << low << " " << mid << " " << high << "\n";
if (query(mid)) high = mid;
else low = mid;
}
if (high == T+1) return -1;
else return high;
}
# | 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... |