# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
494017 | TeaTime | Robots (IOI13_robots) | C++17 | 0 ms | 0 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 <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
ll mx = 1e6 + 100;
int l = 0, r = T + 1;
vector<ll> svd;
for (int i = 0; i < A; i++) svd.push_back(X[i]);
sort(svd.rbegin(), svd.rend());
vector<pair<int, int>> vec;
for (int i = 0; i < T; i++) vec.push_back({ W[i], S[i] });
while (r - l > 1) {
int mid = (l + r) / 2;
vector<int> skip(T);
map<int, int> st;
for (int i = 0; i < B; i++) {
st[Y[i]] += mid;
}
sort(vec.rbegin(), vec.rend());
for (int i = 0; i < T; i++) {
if (st.upper_bound(vec[i].second) != st.end()) {
ll x = (*st.upper_bound(vec[i].second)).first;
st[x]--;
skip[i] = 1;
if (st[x] == 0) st.erase(x);
}
}
ll pt = 0, pt2 = 0;
bool f = 1;
for (int i = 0; i < T; i++) {
if (skip[i]) continue;
if (svd.size() > pt && svd[pt] > vec[i].first) {
pt2++;
if (pt2 == mid) {
pt2 = 0;
pt++;
}
} else {
f = 0;
break;
}
}
if (f) {
r = mid;
} else {
l = mid;
}
}
if (r == T + 1) {
return -1;
} else {
return r;
}
}