#include<bits/stdc++.h>
using namespace std;
#include "robots.h"
bool can(vector<int> X, vector<int> Y, vector<pair<int, int> > Z, int T)
{
int ztp = 0;
priority_queue<pair<int, int> > Q;
for(auto y: Y)
{
while(ztp<(int)Z.size() && Z[ztp].second < y)
Q.emplace(Z[ztp++]);
for(int i=0; i<T && !Q.empty(); ++i)
Q.pop();
}
while(ztp<(int)Z.size()) Q.emplace(Z[ztp++]);
vector<int> remainX;
while(!Q.empty())
{
remainX.push_back(Q.top().first);
Q.pop();
}
sort(remainX.begin(), remainX.end());
int xtp = 0;
for(auto x: X)
for(int i=0; i<T && xtp != (int)remainX.size() && remainX[xtp] < x; ++i)
++xtp;
return xtp == (int)remainX.size();
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
int lo = 0; //impos
int hi = T+1; //pos
vector<int> _X(X, X+A), _Y(Y, Y+B);
vector<pair<int, int> > ws;
for(int i=0; i<T; ++i)
ws.emplace_back(W[i], S[i]);
//sort X, Y, ws according to second value
sort(_X.begin(), _X.end());
sort(_Y.begin(), _Y.end());
sort(ws.begin(), ws.end(), [](pair<int, int> a, pair<int, int> b)
{
return a.second < b.second;
});
while(lo+1!=hi)
{
int mi = (lo+hi)>>1;
if(can(_X, _Y, ws, mi)) hi = mi;
else lo = mi;
}
if(hi == T+1) return -1;
return hi;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2595 ms |
21036 KB |
Output is correct |
5 |
Correct |
2467 ms |
20964 KB |
Output is correct |
6 |
Correct |
179 ms |
3040 KB |
Output is correct |
7 |
Correct |
2745 ms |
20916 KB |
Output is correct |
8 |
Correct |
2479 ms |
20896 KB |
Output is correct |
9 |
Correct |
2468 ms |
20908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
17 ms |
948 KB |
Output is correct |
17 |
Correct |
19 ms |
932 KB |
Output is correct |
18 |
Correct |
25 ms |
1212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2577 ms |
31960 KB |
Output is correct |
11 |
Correct |
2459 ms |
31464 KB |
Output is correct |
12 |
Correct |
180 ms |
4324 KB |
Output is correct |
13 |
Correct |
2590 ms |
29380 KB |
Output is correct |
14 |
Correct |
2472 ms |
31628 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
18 ms |
932 KB |
Output is correct |
22 |
Correct |
2312 ms |
31468 KB |
Output is correct |
23 |
Correct |
2468 ms |
31416 KB |
Output is correct |
24 |
Correct |
1796 ms |
31980 KB |
Output is correct |
25 |
Correct |
839 ms |
26264 KB |
Output is correct |
26 |
Correct |
2222 ms |
33228 KB |
Output is correct |
27 |
Correct |
1000 ms |
31416 KB |
Output is correct |
28 |
Correct |
1154 ms |
31484 KB |
Output is correct |
29 |
Correct |
2425 ms |
32796 KB |
Output is correct |