Submission #628181

# Submission time Handle Problem Language Result Execution time Memory
628181 2022-08-13T07:17:05 Z Trisanu_Das Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
#define ll long long int
#define MAXN 300064
 
ll pond[MAXN], dp[MAXN][2];
 
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
  for (int i = 0; i < M; ++i) pond[X[i] + 1] = W[i];
  for(int i = 2; i < N + 1; i++){
    dp[i][0] = max(dp[i - 1][0], dp[i - 1][1] + pond[i]); dp[i][1] = dp[i - 1][1];
 	if (i > 2) dp[i][1] = max({dp[i][1], dp[i - 2][0] + pond[i - 1], dp[i - 2][1] + pond[i - 1]});
	else dp[i][1] = max(dp[i][1], pond[i - 1]);
  }
  ll ans = 0;
  for (int i = 1; i < N + 1; i++) ans = max({ans, dp[i][0], dp[i][1]});
  return (*max_element(Y.begin(), Y.end()) ? accumulate(W.begin(), W.end(), 0ll) : ans);

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:18:88: error: expected '}' at end of input
   18 |   return (*max_element(Y.begin(), Y.end()) ? accumulate(W.begin(), W.end(), 0ll) : ans);
      |                                                                                        ^
fish.cpp:9:74: note: to match this '{'
    9 | ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
      |                                                                          ^