답안 #627462

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
627462 2022-08-12T15:20:01 Z Trisanu_Das 메기 농장 (IOI22_fish) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
  ll pref0[N + 1], pref1[N + 1];
  for (int i = 0; i < M; i++) {
    if (X[i] == 0) pref0[Y[i] + 1] += W[i];
    else pref1[Y[i] + 1] += W[i];
  }
  for (int i = 1; i <= N; i++) {
    pref0[i] += pref0[i - 1]; pref1[i] += pref1[i - 1];
  }
  ll ans1 = 0, ans2 = 0, ans3 = 0;
  for (int i = 0; i <= N; i++) {
    ans1 = max(s1, pref1[i]);
    ans2 = max(s2, pref0[i]);
    ans3 = max(s3, pref1[N] - pref1[i] + pref0[i]);
  }
  if (N == 2) return max(ans1, ans2);
  else return max(ans1, max(ans2, ans3));
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:16:16: error: 's1' was not declared in this scope; did you mean 'y1'?
   16 |     ans1 = max(s1, pref1[i]);
      |                ^~
      |                y1
fish.cpp:17:16: error: 's2' was not declared in this scope
   17 |     ans2 = max(s2, pref0[i]);
      |                ^~
fish.cpp:18:16: error: 's3' was not declared in this scope
   18 |     ans3 = max(s3, pref1[N] - pref1[i] + pref0[i]);
      |                ^~