Submission #301538

#TimeUsernameProblemLanguageResultExecution timeMemory
301538qiangbaoCarnival Tickets (IOI20_tickets)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <algorithm> #include <vector> #include "tickets.h" #define pb push_back using namespace std; typedef long long ll; typedef pair<ll, ll> pii; ll n, m, kk; vector<vector<ll> > a; ll beg[1501], endi[1501]; vector<pii> subt; ll ansval=0; vector<ll> plamt; vector<vector<int> > ans; ll find_maximum(ll kkk, vector<vector<ll> > x) { ll i, j; n=x.size(), m=x[1].size(), kk=kkk; a=x; for(i=0;i<m;i++) plamt.pb(0); for(i=0;i<n;i++) ans.pb(plamt); for(i=0;i<n;i++) sort(a[i].begin(), a[i].end()); for(i=0;i<n;i++) endi[i]=m-1; for(i=0;i<kk;i++){ subt.clear(); for(j=0;j<n;j++){ ansval+=a[j][endi[j]]; subt.pb({a[j][endi[j]]+a[j][beg[j]], j}); } sort(subt.begin(), subt.end()); for(j=0;j<n/2;j++){ ansval-=subt[j].first; ans[j][beg[j]]=i; beg[subt[j].second]++; } for(j=n/2;j<n;j++){ ans[j][endi[j]]=i; endi[subt[j].second]--; } } allocate_tickets(ans); return ansval; }

Compilation message (stderr)

tickets.cpp: In function 'll find_maximum(ll, std::vector<std::vector<long long int> >)':
tickets.cpp:32:21: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(std::vector<long long int>&)'
   32 |         ans.pb(plamt);
      |                     ^
In file included from /usr/include/c++/9/vector:67,
                 from tickets.cpp:3:
/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 'std::vector<long long 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 'std::vector<long long int>' to 'std::vector<std::vector<int> >::value_type&&' {aka 'std::vector<int>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~