제출 #638740

#제출 시각아이디문제언어결과실행 시간메모리
638740zaneyu로봇 (IOI13_robots)C++14
100 / 100
1589 ms24872 KiB
#include "robots.h" #include<bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<long long,null_type,less_equal<long long>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; //order_of_key #of elements less than x // find_by_order kth element using ll=long long; using ld=long double; using pii=pair<int,int>; #define f first #define s second #define pb push_back #define REP(i,n) for(int i=0;i<n;i++) #define REP1(i,n) for(int i=1;i<=n;i++) #define FILL(n,x) memset(n,x,sizeof(n)) #define ALL(_a) _a.begin(),_a.end() #define sz(x) (int)x.size() #define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end())))) #define GET(v,x) lower_bound(ALL(v),x)-v.begin() const int maxn=5e4+5; const int INF=0x3f3f3f3f; const int MOD=998244353; const ld PI=acos(-1.0l); const ld eps=1e-6; const ll INF64=9e18+1; #define lowb(x) x&(-x) #define MNTO(x,y) x=min(x,(__typeof__(x))y) #define MXTO(x,y) x=max(x,(__typeof__(x))y) int a,b,t,x[maxn],y[maxn]; vector<pii> v; bool wk(int mid){ int p=0; priority_queue<int> pq; REP(i,a){ while(p<t and v[p].f<x[i]){ pq.push(v[p].s); ++p; } int z=mid; while(z-- and sz(pq)){ pq.pop(); } } while(p<t) pq.push(v[p++].s); for(int i=b-1;i>=0;i--){ int z=mid; while(z-- and sz(pq) and pq.top()<y[i]){ pq.pop(); } } return !sz(pq); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { a=A,b=B,t=T; REP(i,T) v.pb({W[i],S[i]}); sort(ALL(v)); REP(i,A) x[i]=X[i]; REP(i,B) y[i]=Y[i]; sort(x,x+a),sort(y,y+b); int l=1,r=T; while(l<r){ int mid=(l+r)/2; if(wk(mid)) r=mid; else l=mid+1; } if(!wk(l)) return -1; return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...