# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
833075 | HaroldVemeno | Robots (IOI13_robots) | C++17 | 2269 ms | 32376 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>
#ifdef GUDEB
#define D(x) cerr << #x << ": " << (x) << '\n';
#define ifdeb if(true)
#else
#define D(x) ;
#define ifdeb if(false)
#endif
#define all(x) begin(x), end(x)
using namespace std;
using ull = unsigned long long;
using ll = long long;
// #define int ll;
struct T {
int w;
int s;
friend bool operator < (T a, T b) {
return a.s < b.s;
}
};
int putaway(int wr, int sr, int ts, int wl[], int sl[], int w[], int s[]) {
sort(wl, wl+wr);
sort(sl, sl+sr);
vector<T> bt(ts);
for(int i = 0; i < ts; ++i) {
bt[i] = {w[i], s[i]};
}
sort(all(bt), [](T a, T b){return a.w < b.w;});
ll b = 0;
ll e = 2001000000;
while(b < e) {
ll m = (b+e)/2;
D(m);
priority_queue<T> wst;
int j = 0;
for(int i = 0; i < wr; ++i) {
D(wl[i])
D(bt[j].w)
while(j < ts && bt[j].w < wl[i]) wst.push(bt[j++]);
for(int k = 0; k < m; ++k) {
if(wst.empty()) break;
D("erase")
wst.pop();
}
}
while(j < ts) {
wst.push(bt[j++]);
}
D(j)
D(wst.size())
vector<T> rst;
while(!wst.empty()) {
rst.push_back(wst.top());
wst.pop();
}
reverse(all(rst));
ifdeb {
for(auto[w, s] : rst) {
cerr << w << ' ' << s << '\n';
}
cerr << '\n' << '\n';
}
j = 0;
int rem = 0;
for(int i = 0; i < sr; ++i) {
D(sl[i])
while(j < rst.size() && rst[j].s < sl[i]) {
++j;
++rem;
}
rem = max(0ll, rem - m);
D(rem);
}
if(rem == 0 && j == rst.size()) {
e = m;
} else {
b = m+1;
}
}
if(b > 2000000010) return -1;
return b;
}
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... |