Submission #957585

#TimeUsernameProblemLanguageResultExecution timeMemory
957585vjudge1Robots (IOI13_robots)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "robots.h" int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) { vector <pii> vec; for(ll i=0;i<a;i++){ vec.pb({x[i],1}); } for(ll i=0;i<t;i++){ vec.pb({w[i],s[i]}); } sort(vec.begin(),vec.end()); sort(y,y+b,greater<int>()); int l=0; int r=t+1; int ans=-1; while(l<r){ int md=(l+r)>>1; bool ok=1; priority_queue<pii>pq; for(int i=0;i<(int)vec.size();i++){ if(vec[i].se==1){ for(int j=0;j<md;j++){ if(pq.size())pq.pop(); } } else{ pq.push(vec[i]); } } priority_queue<ll> pq2; while(pq.size()){ pq2.push(pq.top().se); pq.pop(); } for(int i=0;i<b;i++){ if(!pq2.size())break; if(pq2.top()>=y[i]){ ok=0; break; } else{ for(int j=0;j<md;j++){ if(pq2.size())pq2.pop(); } } } if(ok){ ans=md; r=md; } else{ l=md+1; } } return ans; } /* ---------------------------------------------------go get gold--------------------------------------------------------------------- - If u see the problem dp there's many option to iterate, u can iterate from 1- n or 1 - (possible max number) - If u see the problem that has unexpected constraint u can divide it into 2 problem - If u see the problem that can use binary search, then u can use binser + check condition - in interactive problem there's many trick using binser - kalo misal mau cari yang sama pake pernah ke visit ga bilangan itu - kalo problem yang high itu biasanya optimisasi nya pake 2 array - dp bisa aja kek kamu tenzing balls dimana optimisasi 2 dp - janlup fibonacci - kalo binser mending r = 3 * 1e18 aja - kalo mau dibalik itu pake value nya tinggal diubah ke size */

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:10:13: error: 'pii' was not declared in this scope
   10 |     vector <pii> vec;
      |             ^~~
robots.cpp:10:16: error: template argument 1 is invalid
   10 |     vector <pii> vec;
      |                ^
robots.cpp:10:16: error: template argument 2 is invalid
robots.cpp:11:9: error: 'll' was not declared in this scope
   11 |     for(ll i=0;i<a;i++){
      |         ^~
robots.cpp:11:16: error: 'i' was not declared in this scope
   11 |     for(ll i=0;i<a;i++){
      |                ^
robots.cpp:12:13: error: request for member 'pb' in 'vec', which is of non-class type 'int'
   12 |         vec.pb({x[i],1});
      |             ^~
robots.cpp:14:9: error: 'll' was not declared in this scope
   14 |     for(ll i=0;i<t;i++){
      |         ^~
robots.cpp:14:16: error: 'i' was not declared in this scope
   14 |     for(ll i=0;i<t;i++){
      |                ^
robots.cpp:15:13: error: request for member 'pb' in 'vec', which is of non-class type 'int'
   15 |         vec.pb({w[i],s[i]});
      |             ^~
robots.cpp:17:14: error: request for member 'begin' in 'vec', which is of non-class type 'int'
   17 |     sort(vec.begin(),vec.end());
      |              ^~~~~
robots.cpp:17:26: error: request for member 'end' in 'vec', which is of non-class type 'int'
   17 |     sort(vec.begin(),vec.end());
      |                          ^~~
robots.cpp:25:27: error: template argument 2 is invalid
   25 |         priority_queue<pii>pq;
      |                           ^
robots.cpp:25:27: error: template argument 3 is invalid
robots.cpp:26:32: error: request for member 'size' in 'vec', which is of non-class type 'int'
   26 |         for(int i=0;i<(int)vec.size();i++){
      |                                ^~~~
robots.cpp:27:19: error: invalid types 'int[int]' for array subscript
   27 |             if(vec[i].se==1){
      |                   ^
robots.cpp:29:27: error: request for member 'size' in 'pq', which is of non-class type 'int'
   29 |                     if(pq.size())pq.pop();
      |                           ^~~~
robots.cpp:29:37: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   29 |                     if(pq.size())pq.pop();
      |                                     ^~~
robots.cpp:33:20: error: request for member 'push' in 'pq', which is of non-class type 'int'
   33 |                 pq.push(vec[i]);
      |                    ^~~~
robots.cpp:33:28: error: invalid types 'int[int]' for array subscript
   33 |                 pq.push(vec[i]);
      |                            ^
robots.cpp:36:24: error: 'll' was not declared in this scope; did you mean 'l'?
   36 |         priority_queue<ll> pq2;
      |                        ^~
      |                        l
robots.cpp:36:26: error: template argument 1 is invalid
   36 |         priority_queue<ll> pq2;
      |                          ^
robots.cpp:36:26: error: template argument 2 is invalid
robots.cpp:36:26: error: template argument 3 is invalid
robots.cpp:37:18: error: request for member 'size' in 'pq', which is of non-class type 'int'
   37 |         while(pq.size()){
      |                  ^~~~
robots.cpp:38:17: error: request for member 'push' in 'pq2', which is of non-class type 'int'
   38 |             pq2.push(pq.top().se);
      |                 ^~~~
robots.cpp:38:25: error: request for member 'top' in 'pq', which is of non-class type 'int'
   38 |             pq2.push(pq.top().se);
      |                         ^~~
robots.cpp:39:16: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   39 |             pq.pop();
      |                ^~~
robots.cpp:42:21: error: request for member 'size' in 'pq2', which is of non-class type 'int'
   42 |             if(!pq2.size())break;
      |                     ^~~~
robots.cpp:43:20: error: request for member 'top' in 'pq2', which is of non-class type 'int'
   43 |             if(pq2.top()>=y[i]){
      |                    ^~~
robots.cpp:49:28: error: request for member 'size' in 'pq2', which is of non-class type 'int'
   49 |                     if(pq2.size())pq2.pop();
      |                            ^~~~
robots.cpp:49:39: error: request for member 'pop' in 'pq2', which is of non-class type 'int'
   49 |                     if(pq2.size())pq2.pop();
      |                                       ^~~