제출 #1053747

#제출 시각아이디문제언어결과실행 시간메모리
1053747jer033Catfish Farm (IOI22_fish)C++17
9 / 100
16 ms5824 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];
    vector<ll> dp(N, 0);
    dp[1] = max(fish[0], fish[1]);
    if (N==2)
        return dp[1];
    dp[2] = max(fish[0]+fish[2], fish[1]);
    if (N==3)
        return dp[2];
    dp[3] = max(fish[0], fish[1]) + max(fish[2], fish[3]);
    if (N==4)
        return dp[3];
    for (int i=4; i<N; i++)
    {
        dp[i] = max(dp[i-4]+fish[i-3]+fish[i], max(dp[i-3]+fish[i-2]+fish[i], dp[i-2]+fish[i-1]));
    }
    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...