# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
59395 | spencercompton | Robots (IOI13_robots) | C++17 | 1479 ms | 42476 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 "robots.h"
#include <bits/stdc++.h>
using namespace std;
int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) {
sort(x,x+a);
sort(y,y+b);
int zz = 0;
map<int, int> m;
set<int> ss;
int inf = 2000000001;
for(int i = b-1; i>=0; i--){
m[y[i]] = i;
ss.insert(y[i]);
}
m[inf] = b;
ss.insert(inf);
vector<pair<int, int> > li;
for(int i = 0; i<t; i++){
li.push_back(make_pair(w[i],s[i]));
}
sort(li.begin(),li.end());
int above[t];
for(int i = 0; i<t; i++){
auto it = ss.upper_bound(li[i].second);
above[i] = m[*it];
//mit
}
int low = 1;
int high = t+1;
while(low<high){
int mid = (low+high)/2;
priority_queue<int> pq;
int point = 0;
for(int i = 0; i<a; i++){
while(point<t && li[point].first<x[i]){
pq.push(above[point++]);
}
for(int j = 0; j<mid && pq.size()>0; j++){
pq.pop();
}
}
while(point<t){
pq.push(above[point++]);
}
int cnt[b+1];
for(int i = 0; i<=b; i++){
cnt[i] = 0;
}
while(pq.size()>0){
cnt[pq.top()]++;
pq.pop();
}
long long maxi = 0LL;
bool ok = true;
int sum = 0;
for(int i = b; i>=0 && ok; i--){
sum += cnt[i];
ok &= sum <= maxi;
maxi += mid;
}
if(ok){
high = mid;
}
else{
low = mid+1;
}
}
return (low<=t?low:-1);
}
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... |