# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153824 | Ruxandra985 | Robots (IOI13_robots) | C++14 | 1945 ms | 24224 KiB |
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 <cstdio>
#include <iostream>
#include <algorithm>
#include "robots.h"
#include <vector>
#include <queue>
using namespace std;
int ok (int gmax ,int a , int b , int t , int y[],int s[],vector <int> v[50010] ){
int i,j;
/// pana acum am log 10^6
priority_queue <int> h,h2;
for (i=0;i<=a;i++){
for (j=0;j<v[i].size();j++)
h.push(s[v[i][j]]);
if (i!=a){
for (j=1;j<=gmax && !h.empty();j++)
h.pop(); /// cele mai mari gmax sizeuri le pun aici
}
}
/// in h au ramas cele pe care trebuie tu sa le pui la robotii mici
//if (gmax == 23)
// printf ("%d ",h.size());
for (i=b-1;i>=0;i--){
if (h.empty())
return 1;
if (h.top() > y[i])
return 0;
for (j=1;j<=gmax && !h.empty();j++){
h.pop();
}
}
return h.empty();
}
int putaway (int a , int b , int t , int x[],int y[],int w[],int s[]){
int maxw,maxs,i,k,st,dr,mid;
vector <int> v[50010];
/// cazul cand nu se poate
maxw = maxs = 0;
for (i=0;i<a;i++){
x[i]--;
maxw = max ( maxw , x[i] );
}
for (i=0;i<b;i++){
y[i]--;
maxs = max ( maxs , y[i] );
}
for (i=0;i<t;i++){
if (w[i] > maxw && s[i] > maxs) /// nu se poate
return -1;
}
/// stim ca se poate
/// initial , le pun pe toate ca fiind pentru weak + un elem fictiv
x[a] = 2000000000;
sort (x , x + a);
sort (y , y + b);
k = 0;
for (i=0;i<t;i++){ /// cel mai mic x in care pot sa o pun
st = 0;
dr = a;
while (st<=dr){
mid = (st + dr)/2;
if (x[mid] >= w[i])
dr = mid - 1;
else st = mid + 1;
}
v[st].push_back(i); /// pe st poti sa o pui
if (v[st].size() > k)
k = v[st].size();
}
st = 1;
dr = k;
while (st<=dr){
mid = (st + dr)/2;
if (ok(mid ,a,b,t,y,s , v))
dr = mid - 1;
else st = mid + 1;
}
return st;
}
Compilation message (stderr)
# | 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... |