제출 #627180

#제출 시각아이디문제언어결과실행 시간메모리
627180typ_ik메기 농장 (IOI22_fish)C++17
3 / 100
84 ms7284 KiB
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()

using namespace std;

long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    int block1 = 0;
    for (auto c : X) block1 += (c & 1 ^ 1);
    if (block1 == M)
        return accumulate(all(W), 0ll);

    long long dp[N][2];
    for (int i = 0; i < N; i++)
        for (int j : {0, 1})
            dp[i][j] = 0;

    long long has[N];
    for (int i = 0; i < N; i++)
        has[i] = 0;
    for (int i = 0; i < M; i++)
        has[X[i]] = W[i];

    dp[0][1] = has[0];
    for (int i = 1; i < N; i++) {
        dp[i][1] = has[i] + dp[i-1][0];
        dp[i][0] = max(dp[i-1][1], dp[i-1][0]);
    }

    return max(dp[N - 1][0], dp[N - 1][1]);
}

//main() {
//    int N = 10, M = 4;
//    vector <int> X = {0, 5, 7, 4};
//    vector <int> Y = {0, 0, 0, 0};
//    vector <int> W = {10, 5, 3, 6};
//    cout << max_weights(N, M, X, Y, W) << '\n';
//}

컴파일 시 표준 에러 (stderr) 메시지

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:9:35: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
    9 |     for (auto c : X) block1 += (c & 1 ^ 1);
      |                                 ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...