Submission #383353

#TimeUsernameProblemLanguageResultExecution timeMemory
383353IwanttobreakfreeRice Hub (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
#include "ricehub.h" #include <vector> #include <algorithm> int besthub(int R, int L, int X[], long long B){ vector<int> v(R); for(int i=0;i<R;i++)v[i]=x[i]; sort(v.begin(),v.end()); int l=0,r=R,maxi=0; while(l<=r){ int mid(r-l)/2+l; long long int i=mid+1,sum=0,c=0; while(i<R&&sum<B){ sum+=v[i]-v[mid]; i++; c++; } if(c>=maxi){ maxi=c; r=mid-1; } else l=mid+1; } return maxi; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:5:2: error: 'vector' was not declared in this scope
    5 |  vector<int> v(R);
      |  ^~~~~~
ricehub.cpp:5:2: note: suggested alternatives:
In file included from /usr/include/c++/9/vector:67,
                 from ricehub.cpp:2:
/usr/include/c++/9/bits/stl_vector.h:386:11: note:   'std::vector'
  386 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from ricehub.cpp:2:
/usr/include/c++/9/vector:90:13: note:   'std::pmr::vector'
   90 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
ricehub.cpp:5:9: error: expected primary-expression before 'int'
    5 |  vector<int> v(R);
      |         ^~~
ricehub.cpp:6:22: error: 'v' was not declared in this scope
    6 |  for(int i=0;i<R;i++)v[i]=x[i];
      |                      ^
ricehub.cpp:6:27: error: 'x' was not declared in this scope
    6 |  for(int i=0;i<R;i++)v[i]=x[i];
      |                           ^
ricehub.cpp:7:7: error: 'v' was not declared in this scope
    7 |  sort(v.begin(),v.end());
      |       ^
ricehub.cpp:7:2: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
    7 |  sort(v.begin(),v.end());
      |  ^~~~
      |  std::sort
In file included from /usr/include/c++/9/algorithm:71,
                 from ricehub.cpp:3:
/usr/include/c++/9/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
ricehub.cpp:10:15: error: expected ',' or ';' before '/' token
   10 |   int mid(r-l)/2+l;
      |               ^