Submission #300538

#TimeUsernameProblemLanguageResultExecution timeMemory
300538MuhammetaliCarnival Tickets (IOI20_tickets)C++14
Compilation error
0 ms0 KiB
#include "tickets.h" #include <bits/stdc++.h> #define mp make_pair #define f first #define s second #define sz(x) (int)(x).size() #define rsz resize #define ins insert #define ft front() #define bk back() #define pf push_front #define pb push_back using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef pair<ll,ll> pl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n=x.size(); int m=x[0].size(); vector<vi> answer; for(int i=0;i<n;i++) answer.push_back(0); allocate_tickets(answer); vi v; for (int i=0;i<n;i++) v.pb(x[i][0]); int mid=n/2; if (n%2==0) { ll k=v[mid+1]+v[mid]/2; mid=k; } else mid=v[mid]; ll res=0; for (int i=0;i<n;i++) res+=abs(v[i]-mid); return res; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:26:41: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(int)'
   26 |  for(int i=0;i<n;i++) answer.push_back(0);
      |                                         ^
In file included from /usr/include/c++/9/vector:67,
                 from tickets.h:1,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from 'int' to 'const value_type&' {aka 'const std::vector<int>&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::vector<int> >::value_type&&' {aka 'std::vector<int>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
tickets.cpp:24:6: warning: unused variable 'm' [-Wunused-variable]
   24 |  int m=x[0].size();
      |      ^