Submission #544268

#TimeUsernameProblemLanguageResultExecution timeMemory
544268krit3379Robots (IOI13_robots)C++14
100 / 100
1761 ms26468 KiB
#include<bits/stdc++.h> using namespace std; #include "robots.h" #define N 1000005 struct A{ int w,s; bool operator<(const A& o)const{ return s<o.s; } }; bool comw(A a,A b){ return a.w<b.w; } vector<A> p; priority_queue<A> q; int putaway(int a,int b,int t,int *x,int *y,int *w,int *s){ int i,l,r,mid,now,cnt,ans; sort(x,x+a); sort(y,y+b); for(i=0;i<t;i++){ if(w[i]>=x[a-1]&&s[i]>=y[b-1])return -1; p.push_back({w[i],s[i]}); } sort(p.begin(),p.end(),comw); l=1,r=t; while(l<=r){ mid=(l+r)/2; now=0; for(i=0;i<a;i++){ while(now<t&&p[now].w<x[i])q.push(p[now++]); cnt=mid; while(cnt--&&!q.empty())q.pop(); } while(now<t)q.push(p[now++]); for(i=b-1;i>=0;i--){ cnt=mid; while(cnt--&&!q.empty()&&q.top().s<y[i])q.pop(); } if(q.empty())ans=mid,r=mid-1; else l=mid+1; while(!q.empty())q.pop(); } return ans; }

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:21:27: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   21 |     int i,l,r,mid,now,cnt,ans;
      |                           ^~~
#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...