Submission #1135538

#TimeUsernameProblemLanguageResultExecution timeMemory
1135538PekibanCatfish Farm (IOI22_fish)C++20
Compilation error
0 ms0 KiB
#include "fish.h" #include <bits/stdc++.h> #define pb push_back using namespace std; using ll = long long; ll max_weights(int n, int m, vector<int> X, vector<int> Y, vector<int> W) { vector<array<ll, 2>> a[n]; vector<ll> S[n]; ll SUM = 0; for (int i = 0; i < m; ++i) a[X[i]].pb({Y[i], W[i]}); for (int i = 0; i < n; ++i) { a[i].pb({-1, 0}); sort(a[i].begin(), a[i].end()); S[i] = {0}; for (auto &[y, w] : a[i]) { if (y >= 0) { S[i].pb(S[i].back() + w); } } SUM += S[i].back(); } ll dp[n][n][2]; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) dp[i][j][0] = dp[i][j][1] = 0; } for (int i = 0; i < n; ++i) dp[0][i][0] = dp[0][i][1] = 0; auto sum = [&](int i, int h) { array<ll, 2> cr = {h, (int)1e9}; return S[i][upper_bound(a[i].begin(), a[i].end(), cr) - a[i].begin() - 1]; }; ll mx = 0; for (int i = 1; i < n; ++i) { for (int h = 0; h < n; ++h) { if (i == 1) dp[i][h][0] = sum(0, h); for (int h2 = 0; h2 < n; ++h2) { if (h2 <= h) { dp[i][h][0] = max(sum(i-1, h) - sum(i-1, h2) + dp[i-1][h2][0], dp[i][h][0]); } if (h2 >= h) dp[i][h][1] = max(sum(i, h2) - sum(i, h) + dp[i-1][h2][1], dp[i][h][1]); if (i >= 2) dp[i][h][0] = max(sum(i-1, max(h, h2)) + dp[i-2][h2][1] , dp[i][h][0]); } mx = max(mx, dp[i][h][0], dp[i][h][1]); } dp[i][n-1][0] = dp[i][n-1][1] = max({dp[i][n-1][0], dp[i][n-1][1]}); } return mx; }

Compilation message (stderr)

In file included from /usr/include/c++/11/vector:60,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
fish.cpp:43:21:   required from here
/usr/include/c++/11/bits/stl_algobase.h:303:17: error: '__comp' cannot be used as a function
  303 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~