제출 #1044994

#제출 시각아이디문제언어결과실행 시간메모리
1044994ender메기 농장 (IOI22_fish)C++17
0 / 100
13 ms6892 KiB
#include "fish.h"
#include <bits/stdc++.h>
#include <vector>

using namespace std;

const long long INF = 1e18;

const int MAXN = 1e5;

int n;

long long memo[MAXN];
bool cached[MAXN];

int a[MAXN];

long long dp(int i, bool check){

  if(i >= n) return 0;

  if(cached[i]) return memo[i];

  long long res = -INF;

  if(check){

    long long act1 = dp(i+2, true) + a[i+1];
    long long act2 = dp(i+1, false);

    res = max({res, act1, act2});

  } else {

    long long act1 = dp(i+2, true) + a[i+1] + a[i-1];
    long long act2 = dp(i+1, false);

    res = max({res, act1, act2});

  }


  memo[i] = res;
  cached[i] = true;

  return res;

}

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {

  n = N;

  for(int i = 0; i < n; ++i) a[i] = 0;

  for(int i = 0; i<M; ++i){

    a[X[i]] = W[i];

  }

  return dp(0, true);

}
#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...