Submission #1044998

# Submission time Handle Problem Language Result Execution time Memory
1044998 2024-08-05T15:29:12 Z ender Catfish Farm (IOI22_fish) C++17
0 / 100
14 ms 5464 KB
#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-1) 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 time Memory Grader output
1 Incorrect 14 ms 5464 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3928 KB Output is correct
2 Correct 2 ms 4028 KB Output is correct
3 Incorrect 10 ms 4956 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '27384291159897'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3928 KB Output is correct
2 Correct 2 ms 4028 KB Output is correct
3 Incorrect 10 ms 4956 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '27384291159897'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 5464 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453'
2 Halted 0 ms 0 KB -