Submission #633001

# Submission time Handle Problem Language Result Execution time Memory
633001 2022-08-21T11:45:43 Z stefanlin Catfish Farm (IOI22_fish) C++17
12 / 100
86 ms 8504 KB
#include "fish.h"

#include <vector>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <cstring>

bool locatedAt0(std::vector<int> Y) {
    for (auto y : Y) {
        if (y != 0) {
            return false;
        }
    }
    return true;
}

bool locateAtEven(std::vector<int> X) {
    for (auto x : X) {
        if (x % 2 != 0) {
            return false;
        }
    }
    return true;
}

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
    if (locatedAt0(Y)) {
        long long a[N + 1];
        long long dp[N + 1][2];
        memset(a, 0, sizeof a);
        memset(dp, 0, sizeof dp);
        for (int i = 0; i < M; ++i) {
            a[X[i]] = W[i];
        }
        dp[0][0] = 0;
        dp[0][1] = a[1];
        dp[1][0] = a[1];
        dp[1][1] = a[0] + a[2];
        for (int i = 2; i < N; ++i) {
            dp[i][0] = std::max(dp[i - 1][1], dp[i - 1][0]),
            dp[i][1] = std::max(dp[i - 2][0] + a[i - 1] + a[i + 1], dp[i - 2][1] + a[i + 1]);
            dp[i][1] = std::max(dp[i - 1][1] - a[i] + a[i + 1], dp[i][1]);
        }
        return std::max(dp[N - 1][0], dp[N - 1][1]);
    }
    if (locateAtEven(X)) {
        long long ans = 0;
        for (auto w : W) {
            ans += w;
        }
        return ans;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2448 KB Output is correct
2 Correct 27 ms 3088 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 86 ms 8492 KB Output is correct
6 Correct 80 ms 8504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2516 KB Output is correct
3 Correct 16 ms 3584 KB Output is correct
4 Correct 12 ms 3412 KB Output is correct
5 Correct 28 ms 4924 KB Output is correct
6 Correct 22 ms 4880 KB Output is correct
7 Correct 26 ms 4932 KB Output is correct
8 Correct 26 ms 4936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2516 KB Output is correct
3 Correct 16 ms 3584 KB Output is correct
4 Correct 12 ms 3412 KB Output is correct
5 Correct 28 ms 4924 KB Output is correct
6 Correct 22 ms 4880 KB Output is correct
7 Correct 26 ms 4932 KB Output is correct
8 Correct 26 ms 4936 KB Output is correct
9 Incorrect 23 ms 3024 KB 1st lines differ - on the 1st token, expected: '99999', found: '0'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2448 KB Output is correct
2 Correct 27 ms 3088 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 86 ms 8492 KB Output is correct
6 Correct 80 ms 8504 KB Output is correct
7 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '0'
8 Halted 0 ms 0 KB -