This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
int N, M, px[1000009], py[1000009], col[50009]; vector<int> V[50009];
bool solve(int pos) {
priority_queue<int, vector<int>, less<int>> Q;
for (int i = 0; i <= N; i++) {
for (int j = 0; j < V[i].size(); j++) Q.push(V[i][j]);
if (i == N) break;
int cntv = 0;
while (!Q.empty() && cntv < pos) {
Q.pop(); cntv++;
}
}
for (int i = 0; i <= M; i++) col[i] = 0;
while (!Q.empty()) { col[Q.top()]++; Q.pop(); }
if (col[M] >= 1) return false;
long long sum = 0, L = 0;
for (int i = M - 1; i >= 0; i--) {
sum += pos; L += col[i];
if (L > sum) return false;
}
return true;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
N = A; M = B;
sort(X, X + A);
sort(Y, Y + B);
for (int i = 0; i < T; i++) {
int pos1 = upper_bound(X, X + A, W[i]) - X; px[i] = pos1;
int pos2 = upper_bound(Y, Y + B, S[i]) - Y; py[i] = pos2;
if (pos1 == A && pos2 == B) return -1;
}
for (int i = 0; i < T; i++) V[px[i]].push_back(py[i]);
int L = 1, R = 1000005, MM, minx = (1 << 30);
for (int i = 0; i < 25; i++) {
MM = (L + R) / 2;
bool t = solve(MM);
if (t == true) { R = MM; minx = min(minx, MM); }
else { L = MM; }
}
return minx;
}
Compilation message (stderr)
robots.cpp: In function 'bool solve(int)':
robots.cpp:10:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < V[i].size(); j++) Q.push(V[i][j]);
~~^~~~~~~~~~~~~
# | 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... |