Submission #565906

#TimeUsernameProblemLanguageResultExecution timeMemory
565906sidonCarnival Tickets (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include "tickets.h" #include "bits/stdc++.h" using namespace std; using ll = long long; ll find_maximum(int k, vector<vector<int>> x) { int n = x.size(), m = x[0].size(); vector<vector<int>> g(n, vector<int> (m, -1)); ll res {}; vector<array<ll, 3>> a; int b[n]; for(int i = n; i--; ) { b[i] = k; ll cur {}; for(int j = 0; j < k; ++j) cur -= x[i][j]; res += cur; for(int j = k; j--; ) { ll add = x[i][j] + x[i][m+j-k]; a.push_back({add, i, j}); cur += add; } } sort(rbegin(a), rend(a)); for(int i = (k * n / 2); i--; ) { res += a[i][0]; b[a[i][1]] = min(b[a[i][1]], a[i][2]); } for(int i = n; i--; ) { for(int j = b[i]; j--; ) --g[i][j]; for(int j = 0; j < k - b[i]; ++j) ++g[i][m-1-j]; } int l[n] {}, r[n]; bool vis[n]; fill(r, r + n, m-1); for(int c = 0; c < k; ++c) { int cnt {}; fill(vis, vis + n, 0); for(int i = n; i--; ) { if(g[i][l[i]] > -2) g[i][r[i]--] = c, ++cnt, vis[i] = 1; if(g[i][r[i]] < 0) g[i][l[i]++] = c, --cnt, vis[i] = 1; } for(int i = n; i--; ) if(!vis[i]) { if(cnt < 0) g[i][r[i]--] = c, ++cnt; else g[i][l[i]++] = c, --cnt; } } allocate_tickets(g); return res; }

Compilation message (stderr)

tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:32:39: error: no matching function for call to 'min(int&, std::array<long long int, 3>::value_type&)'
   32 |   b[a[i][1]] = min(b[a[i][1]], a[i][2]);
      |                                       ^
In file included from /usr/include/c++/10/vector:60,
                 from tickets.h:1,
                 from tickets.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
tickets.cpp:32:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::array<long long int, 3>::value_type' {aka 'long long int'})
   32 |   b[a[i][1]] = min(b[a[i][1]], a[i][2]);
      |                                       ^
In file included from /usr/include/c++/10/vector:60,
                 from tickets.h:1,
                 from tickets.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
tickets.cpp:32:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::array<long long int, 3>::value_type' {aka 'long long int'})
   32 |   b[a[i][1]] = min(b[a[i][1]], a[i][2]);
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tickets.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
tickets.cpp:32:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |   b[a[i][1]] = min(b[a[i][1]], a[i][2]);
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tickets.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
tickets.cpp:32:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |   b[a[i][1]] = min(b[a[i][1]], a[i][2]);
      |                                       ^