Submission #309960

#TimeUsernameProblemLanguageResultExecution timeMemory
309960juggernautRobots (IOI13_robots)C++14
0 / 100
1 ms512 KiB
#include"robots.h" #include<bits/stdc++.h> #define fr first #define sc second //#include"grader.c" using namespace std; int a,b,t,x[50005],y[50005]; pair<int,int>toy[1000005]; bool check(int m){ multiset<int>q; for(int i=0,tt=0;i<=a;i++){ for(;tt<t&&toy[tt].fr<x[i];tt++)q.insert(-toy[tt].sc); if(i!=a)for(int j=0;j<m&&(!q.empty());j++)q.erase(q.begin()); } for(int i=b-1;i>=0&&(q.empty()||-(*q.begin())<y[i]);i--) for(int j=0;j<m&&(!q.empty());j++)q.erase(q.begin()); return q.empty(); } int putaway(int A,int B,int T,int X[],int Y[],int W[],int S[]){ a=A,b=B,t=T; x[a]=2e9+1; for(int i=0;i<a;i++)x[i]=X[i]; for(int i=0;i<b;i++)y[i]=Y[i]; for(int i=0;i<t;i++)toy[i]={W[i],S[i]}; sort(x,x+a); sort(y,y+b); sort(toy,toy+t); if(!check(t))return -1; if(B==0){ vector<pair<int,int>>toy1; for(int i=0;i<t;i++)toy1.push_back(toy[i]); if(X[A-1] <= toy1[T-1].first ) return -1; int res = (T + A -1 )/ A; for(int i = 0; i < A - 1 ;i++){ if( X[i] <= toy1[0].first){ res = max ( res, (T + ( A - i- 1) -1 )/ (A - i -1 )); } int ind = upper_bound(toy1.begin(), toy1.end(), make_pair (X[i], 2000000002)) - toy1.begin() ; res = max ( res, (T - ind + (A-i-1) - 1) / ( A - i - 1)); } return res; } int l=1,r=t; while(l<r){ int mid=(l+r)>>1; if(check(mid))r=mid; else l=mid+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...