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 <bits/stdc++.h>
#include "robots.h"
using namespace std;
vector<int> x,y;
vector<pair<int,int>> robots;
bool cmp(pair<int,int> A, pair<int,int> B)
{
return A.second < B.second;
}
bool pot(int k)
{
sort(robots.begin(),robots.end());
vector<bool> luat(robots.size());
set<pair<int,int>> s;///y si indexul
int i1 = 0;
for (int i = 0; i < x.size(); i++)
{
while (i1 < robots.size() and robots[i1].first <= x[i])
{
s.insert({robots[i1].second,i1});
i1++;
}
int ct = k;
while (!s.empty() and ct > 0)
{
ct--;
pair<int,int> idk = *s.rbegin();
s.erase(idk);
luat[idk.second] = true;
}
}
s.clear();
vector<pair<int,int>> r;
for (int i = 0; i < robots.size(); i++)
if (!luat[i])
r.push_back(robots[i]);
sort(r.begin(),r.end(),cmp);
i1 = 0;
for (int i = 0; i < y.size(); i++)
{
while (i1 < r.size() and r[i1].second <= y[i])
{
s.insert({r[i1].first,i1});
i1++;
}
int ct = k;
while (!s.empty() and ct > 0)
{
ct--;
pair<int,int> idk = *s.rbegin();
s.erase(idk);
}
}
if (s.empty())
return true;
return false;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[])
{
sort(X, X + A);
sort(Y, Y + B);
for (int i = 0; i < A; i++)
x.push_back(X[i]);
for (int i = 0; i < B; i++)
y.push_back(Y[i]);
for (int i = 0; i < T; i++)
robots.push_back({W[i],S[i]});
for (auto it : robots)
if ((A == 0 or it.first > X[A - 1]) and (B == 0 or it.second > Y[B - 1]))
return -1;
int st = 0,pas = 1 << 19;
while (pas != 0)
{
if (!pot(st + pas))
st += pas;
pas /= 2;
}
return st + 1;
}
Compilation message (stderr)
robots.cpp: In function 'bool pot(int)':
robots.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for (int i = 0; i < x.size(); i++)
| ~~^~~~~~~~~~
robots.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | while (i1 < robots.size() and robots[i1].first <= x[i])
| ~~~^~~~~~~~~~~~~~~
robots.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for (int i = 0; i < robots.size(); i++)
| ~~^~~~~~~~~~~~~~~
robots.cpp:43:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for (int i = 0; i < y.size(); i++)
| ~~^~~~~~~~~~
robots.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | while (i1 < r.size() and r[i1].second <= y[i])
| ~~~^~~~~~~~~~
# | 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... |