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>
typedef int ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
bool lmao(vector<ll>& stuff, vector<ll>& robot, ll k){
reverse(stuff.begin(), stuff.end());
ll cur = 0;
for (auto&i : robot){
ll cnt = 0;
while (cur < stuff.size() && cnt < k){
if (stuff[cur] < i) cur++, cnt++;
else break;
}
}
if (cur == stuff.size()) return true;
else return false;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
vector<ll> x(A),y(B);
vector<vector<ll>> lol(T);
FOR(i,0,A) x[i] = (X[i]);
FOR(i,0,B) y[i] = (Y[i]);
FOR(i,0,T) lol[i] = {W[i], S[i]};
sort(x.begin(), x.end());
sort(y.begin(), y.end());
sort(lol.begin(), lol.end());
ll l = 1;
ll r = T+1;
priority_queue<ll> sus;
while (l<r){
ll mid = (l+r)/2;
ll cur = 0;
for (auto&i : x){
while (cur < lol.size()){
if (lol[cur][0] < i) sus.push(lol[cur][1]), cur++;
else break;
}
FOR(k,0,mid){
if (sus.size()) sus.pop();
else break;
}
}
while (cur < lol.size()) sus.push(lol[cur][1]), cur++;
vector<ll> idk;
while (sus.size()){
idk.push_back(sus.top());
sus.pop();
}
if (lmao(idk,y,mid)) r = mid;
else l = mid+1;
}
if (l==T+1) return -1;
else return l;
}
Compilation message (stderr)
robots.cpp: In function 'bool lmao(std::vector<int>&, std::vector<int>&, ll)':
robots.cpp:17:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | while (cur < stuff.size() && cnt < k){
| ~~~~^~~~~~~~~~~~~~
robots.cpp:22:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | if (cur == stuff.size()) return true;
| ~~~~^~~~~~~~~~~~~~~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:49:24: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | while (cur < lol.size()){
| ~~~~^~~~~~~~~~~~
robots.cpp:58:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | while (cur < lol.size()) sus.push(lol[cur][1]), cur++;
| ~~~~^~~~~~~~~~~~
# | 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... |