Submission #1336059

#TimeUsernameProblemLanguageResultExecution timeMemory
1336059YSH2020Catfish Farm (IOI22_fish)C++20
Compilation error
0 ms0 KiB
#include "fish.h"

#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 pref[2][N+1];
	memset(pref,0,sizeof(pref));
	for (int i = 0; i < M; i++) {
		pref[X[i]][Y[i]+1]+=W[i];
	}
	for (int i = 1; i <= N; i++) {
		pref[0][i]+=pref[0][i-1];
		pref[1][i]+=pref[1][i-1];
	}
	if (N<3) return max(pref[0][N], pref[1][N]);
	long long ans=max(pref[0][N], pref[1][N]);
	for (int i = 1; i <= N; i++) {
		ans=max(ans,pref[0][i]+pref[1][n]-pref[1][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:48: error: 'n' was not declared in this scope
   18 |                 ans=max(ans,pref[0][i]+pref[1][n]-pref[1][i-1]);
      |                                                ^