답안 #849313

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
849313 2023-09-14T13:06:32 Z sonamoo 메기 농장 (IOI22_fish) C++17
컴파일 오류
0 ms 0 KB
vector<pair<ll,ll> > fish;
long long ans;
long long a1[100005] , a2[100005] , ps1[100005] , ps2[100005];
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
    for (int i = 0; i < M; i++) {
        if (X[i] == 0) a1[Y[i]+1] += W[i];
        else a2[Y[i]+1] += W[i];
    }

    for (int i = 1; i <= N; i++) {
        ps1[i] = ps1[i-1]+a1[i];
        ps2[i] = ps2[i-1]+a2[i];
    }

    for (int i = 0; i <= N; i++) {
        ans = max(ans , ps2[N]-ps2[i]+ps1[i]);
        ans = max(ans , ps1[N]-ps1[i]+ps2[i]);
    }

    return ans;
}

Compilation message

fish.cpp:2:1: error: 'vector' does not name a type
    2 | vector<pair<ll,ll> > fish;
      | ^~~~~~
fish.cpp:5:37: error: 'std::vector' has not been declared
    5 | long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
      |                                     ^~~
fish.cpp:5:48: error: expected ',' or '...' before '<' token
    5 | long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
      |                                                ^
fish.cpp: In function 'long long int max_weights(int, int, int)':
fish.cpp:7:13: error: 'X' was not declared in this scope
    7 |         if (X[i] == 0) a1[Y[i]+1] += W[i];
      |             ^
fish.cpp:7:27: error: 'Y' was not declared in this scope
    7 |         if (X[i] == 0) a1[Y[i]+1] += W[i];
      |                           ^
fish.cpp:7:38: error: 'W' was not declared in this scope
    7 |         if (X[i] == 0) a1[Y[i]+1] += W[i];
      |                                      ^
fish.cpp:8:17: error: 'Y' was not declared in this scope
    8 |         else a2[Y[i]+1] += W[i];
      |                 ^
fish.cpp:8:28: error: 'W' was not declared in this scope
    8 |         else a2[Y[i]+1] += W[i];
      |                            ^
fish.cpp:17:15: error: 'max' was not declared in this scope
   17 |         ans = max(ans , ps2[N]-ps2[i]+ps1[i]);
      |               ^~~