이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///~~~LOTA~~~///
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
bool check(int t,vector<pii>& v,multiset<int>& a,multiset<int>& b,int d){
map<int,int> A,B;
for(auto& i:a)
A[i]+=d;
for(auto& i:b)
B[i]+=d;
int x;
for(int i=t-1;i>=0;i--){
x=(*B.upper_bound(v[i].ss)).ff;
if(x!=INT_MAX){
B[x]--;
if(B[x]==0)
B.erase(B.upper_bound(v[i].ss));
continue;
}
x=(*A.upper_bound(v[i].ff)).ff;
if(x!=INT_MAX){
A[x]--;
if(A[x]==0)
A.erase(A.upper_bound(v[i].ff));
continue;
}
return 0;
}
return 1;
}
int putaway(int n,int m,int t,int x[],int y[],int w[],int s[]){
int mx,my;
vector<pii> v;
multiset<int> a,b;
a.insert(INT_MAX);
b.insert(INT_MAX);
for(int i=mx=0;i<n;i++){
a.insert(x[i]);
mx=max(mx,x[i]);
}
for(int i=my=0;i<m;i++){
b.insert(y[i]);
my=max(my,y[i]);
}
for(int i=0;i<t;i++){
v.append({w[i],s[i]});
if(w[i]>=mx && s[i]>=my)
return -1;
}
sort(all(v));
int o=0;
for(int i=524288;i>0;i/=2)
if(!check(t,v,a,b,o+i))
o+=i;
return o+1;
}
# | 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... |