This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int inf = INT_MAX;
const int mod = 1e9+7;
const int maxn = 5002;
#include "robots.h"
int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) {
int l = 0, r = t + 1;
vt<pii> v;
map<int, int> hmt;
for(int i = 0; i < a; i++){
v.pb({x[i] - 1, inf});
}
for(int i = 0; i < t; i++){
v.pb({w[i], s[i]});
}
sort(all(v));
set<int> hv;
while(l + 1 < r){
int mid = l + (r - l) / 2;
for(int i = 0; i < b; i++){
hmt[y[i] - 1] += mid;
hv.insert(y[i] - 1);
}
set<int> help;
bool ok = 1;
for(int i = t + a - 1, cnt = 0; i >= 0; i--){
if(v[i].ss == inf){
cnt += mid;
}
else {
help.insert(v[i].ss);
if(cnt)cnt--;
else {
int x = *help.begin();
help.erase(help.begin());
if(hv.lower_bound(x) == hv.end()){
ok = 0;
break;
}
x = *hv.lower_bound(x);
hmt[x]--;
if(hmt[x] == 0)hv.erase(x);
}
}
}
for(int i = 0; i < b; i++)hmt[y[i]] = 0;
if(ok)r = mid;
else l = mid;
}
if(r > t)return -1;
return r;
}
//int main() {
//ios_base::sync_with_stdio(0);
//cin.tie(0);
//int a, b, t;
//cin >> a >> b >> t;
//int x[a], y[b], w[t], s[t];
//for(int i = 0; i < a; i++)cin >> x[i];
//for(int i = 0; i < b; i++)cin >> y[i];
//for(int i = 0; i < t; i++)cin >> w[i] >> s[i];
//cout << putaway(a, b, t, x, y, w, s);
//return 0;
//}
# | 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... |