Submission #1053741

#TimeUsernameProblemLanguageResultExecution timeMemory
1053741jer033Catfish Farm (IOI22_fish)C++17
0 / 100
12 ms3672 KiB
#include "fish.h"
#include <bits/stdc++.h>
#include <vector>
using ll = long long;
using namespace std;

long long max_weights_st1(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
    long long y = 0;
    for (int i=0; i<M; i++)
    {
        long long x = W[i];
        y+=x;
    }
    return y;
}

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
    vector<long long> fish(N, 0);
    //we can consider empty cells to have catfish worth 0
    for (int i=0; i<M; i++)
        fish[X[i]] = W[i];
    if (N==2)
        return max(fish[0], fish[1]);
    vector<ll> dp(N, 0);
    dp[1] = max(fish[0], fish[1]);
    dp[2] = max(fish[0]+fish[2], fish[1]);
    for (int i=3; i<N; i++)
    {
        dp[i] = max(fish[i], fish[i-1])+dp[i-2];
    }
    return dp[N-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...