Submission #785100

#TimeUsernameProblemLanguageResultExecution timeMemory
785100khshgCatfish Farm (IOI22_fish)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { long long ans = 0; vector<int> c(N + 1); for(int i = 0; i < M; ++i) { c[X[i]] = W[i]; } vector<array<long long, 2>> dp(N + 1); dp[0][0] = 0; dp[0][1] = c[1]; ans = c[1]; for(int i = 1; i < N; ++i) { dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]); dp[i][1] = dp[i - 1][1] - c[i]; dp[i][1] = max(dp[i][1], (i - 2 < 0 ? 0 : dp[i - 2][0]) + c[i - 1]); dp[i][1] = max(dp[i][1], (i - 2 < 0 ? 0 : dp[i - 2][1]); dp[i][1] += c[i + 1]; ans = max(dp[i][0], dp[i][1]); } return ans; }

Compilation message (stderr)

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:18:58: error: expected ')' before ';' token
   18 |   dp[i][1] = max(dp[i][1], (i - 2 < 0 ? 0 : dp[i - 2][1]);
      |                 ~                                        ^
      |                                                          )