Submission #729820

#TimeUsernameProblemLanguageResultExecution timeMemory
729820caganyanmazCatfish Farm (IOI22_fish)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define int int64_t using namespace std; int max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) { array<vector<array<int, 2>>, 2> t; for (int i = 0; i < m; i++) if (x[i] <= 1) t[x[i]].pb({y[i], w[i]}); else assert(false); for (int i = 0; i < 2; i++) sort(t.begin(), t.end()); array<vector<int>, 2> p; for (int i = 0; i < 2; i++) { p = vector<int>(n+1); int _next = 0; for (int j = 0; j < n; j++) { p[i][j] = p[i][j-1]; if (_next < t[i].size() && j > t[i][_next][0]) p[j] += t[i][_next++][1]; } } int best = 0; for (int i = 0; i < n; i++) best = max(best, p[0][i] + p[1][n] - p[1][i]); return best; }

Compilation message (stderr)

fish.cpp: In function 'int64_t max_weights(int64_t, int64_t, std::vector<long int>, std::vector<long int>, std::vector<long int>)':
fish.cpp:19:36: error: no match for 'operator=' (operand types are 'std::array<std::vector<long int>, 2>' and 'std::vector<long int>')
   19 |                 p = vector<int>(n+1);
      |                                    ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from fish.cpp:1:
/usr/include/c++/10/array:94:12: note: candidate: 'std::array<std::vector<long int>, 2>& std::array<std::vector<long int>, 2>::operator=(const std::array<std::vector<long int>, 2>&)'
   94 |     struct array
      |            ^~~~~
/usr/include/c++/10/array:94:12: note:   no known conversion for argument 1 from 'std::vector<long int>' to 'const std::array<std::vector<long int>, 2>&'
/usr/include/c++/10/array:94:12: note: candidate: 'std::array<std::vector<long int>, 2>& std::array<std::vector<long int>, 2>::operator=(std::array<std::vector<long int>, 2>&&)'
/usr/include/c++/10/array:94:12: note:   no known conversion for argument 1 from 'std::vector<long int>' to 'std::array<std::vector<long int>, 2>&&'
fish.cpp:24:35: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<std::array<long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |                         if (_next < t[i].size() && j > t[i][_next][0]) p[j] += t[i][_next++][1];
      |                             ~~~~~~^~~~~~~~~~~~~
fish.cpp:24:77: error: no match for 'operator+=' (operand types are 'std::array<std::vector<long int>, 2>::value_type' {aka 'std::vector<long int>'} and 'std::array<long int, 2>::value_type' {aka 'long int'})
   24 |                         if (_next < t[i].size() && j > t[i][_next][0]) p[j] += t[i][_next++][1];