Submission #964538

#TimeUsernameProblemLanguageResultExecution timeMemory
964538UmairAhmadMirzaRobots (IOI13_robots)C++14
100 / 100
1371 ms28860 KiB
#include <bits/stdc++.h> #include <robots.h> using namespace std; deque<pair<int,int>> toy,temp; bool check(int A,int B,int T,int X[], int Y[],int lim){ toy=temp; priority_queue<int> v; for (int i = 0; i < A; ++i) { while(toy.size()){ if(toy[0].first>=X[i]) break; v.push(toy[0].second); toy.pop_front(); } int cnt=0; while(v.size() && cnt<lim){ cnt++; v.pop(); } } for(auto i:toy) v.push(i.second); toy.clear(); stack<int> sz; while(v.size()){ sz.push(v.top()); v.pop(); } int p=0; int cnt=0; int i=0; while(sz.size() && p<B){ if(sz.top()>=Y[p]){ p++; cnt=0; } else if(cnt==lim){ p++; cnt=0; } else{ cnt++; sz.pop(); } } if(sz.size()==0) return 1; return 0; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){ int maxX=0,maxY=0; for (int i = 0; i < A; ++i) maxX=max(maxX,X[i]); for (int i = 0; i < B; ++i) maxY=max(maxY,Y[i]); for (int i = 0; i < T; ++i){ if(W[i]>=maxX && S[i]>=maxY) return -1; temp.push_back({W[i],S[i]}); } sort(temp.begin(), temp.end()); sort(X,X+A); sort(Y,Y+B); int low=0,high=T; while(high-low>1){ int mid=(low+high)/2; if(check(A,B,T,X,Y,mid)) high=mid; else low=mid; } return high; }

Compilation message (stderr)

robots.cpp: In function 'bool check(int, int, int, int*, int*, int)':
robots.cpp:32:6: warning: unused variable 'i' [-Wunused-variable]
   32 |  int i=0;
      |      ^
#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...