Submission #993280

#TimeUsernameProblemLanguageResultExecution timeMemory
993280MrDebooRobots (IOI13_robots)C++17
0 / 100
1 ms348 KiB
#include "robots.h" #include "bits/stdc++.h" using namespace std; vector<pair<int,int>>v; int mid; deque<int>a,b; map<pair<int,int>,int>mp; bool bol; bool slv(){ priority_queue<pair<int,int>>pq; int l=0; for(int i=0;i<a.size();i++){ while(l<v.size()&&a[i]>v[l].first){ if(bol&&mp[v[l]])mp[v[l]]--; else pq.push({v[l].second,v[l].first}); l++; } int k=mid; while(pq.size()&&k--){ if(!bol)mp[pq.top()]++; pq.pop(); } } return pq.empty()&&a.back()>v.back().first; } int putaway(int A, int B, int t, int x[], int y[], int w[], int s[]) { for(int i=0;i<t;i++)v.push_back({w[i],s[i]}); for(int i=0;i<A;i++)a.push_back(x[i]); for(int i=0;i<B;i++)b.push_back(y[i]); sort(a.begin(),a.end()); sort(b.begin(),b.end()); int l=1,r=t,f=-1; vector<pair<int,int>>vec=v; sort(vec.begin(),vec.end()); vector<pair<int,int>>vec2=v; for(auto &i:vec2)swap(i.first,i.second); sort(vec2.begin(),vec2.end()); while(l<=r){ mid=(l+r)/2; v=vec; mp.clear(); bol=0; slv(); bol=1; v=vec2; swap(a,b); bool bl=slv(); swap(a,b); if(bl){ r=mid-1; f=mid; }else l=mid+1; } return f; }

Compilation message (stderr)

robots.cpp: In function 'bool slv()':
robots.cpp:12:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i=0;i<a.size();i++){
      |                 ~^~~~~~~~~
robots.cpp:13:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         while(l<v.size()&&a[i]>v[l].first){
      |               ~^~~~~~~~~
#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...