Submission #628243

# Submission time Handle Problem Language Result Execution time Memory
628243 2022-08-13T08:52:21 Z c28dnv9q3 Catfish Farm (IOI22_fish) C++17
9 / 100
30 ms 12116 KB
#include "fish.h"
#include <vector>

using namespace std;
using ll = long long;

const int N_MAX = 100005;

ll v[N_MAX];
ll dp[N_MAX];
bool got[N_MAX];

ll f(int i) {
  if (i == 0) return 0;
  if (got[i]) return dp[i];
  ll ans = f(i-1);
  if (i == 1) {
    ans = max(v[0], v[1]);
  } else if (i == 2) {
    ans = max(ans, v[0] + v[2]);
  }
  if (i >= 2) {
    ans = max(ans, v[i-1] + f(i-2));
  }
  if (i >= 3) {
    ans = max(ans, f(i-3) + v[i] + v[i-2]);
  }
  if (i >= 4) {
    ans = max(ans, f(i-4) + v[i] + v[i-3]);
  }

  got[i] = true;
  return dp[i] = ans;
}

ll max_weights(
  int N, int M, vector<int> X, vector<int> Y, vector<int> W
) {
  for (int i = 0; i < M; i++)
    v[X[i]] = W[i];

  return f(N-1);
}
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 9956 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 212 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 6 ms 8916 KB Output is correct
2 Correct 6 ms 8916 KB Output is correct
3 Correct 19 ms 10060 KB Output is correct
4 Correct 15 ms 10336 KB Output is correct
5 Correct 30 ms 12092 KB Output is correct
6 Correct 27 ms 12108 KB Output is correct
7 Correct 28 ms 12116 KB Output is correct
8 Correct 30 ms 12032 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: '2'
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: '2'
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: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8916 KB Output is correct
2 Correct 6 ms 8916 KB Output is correct
3 Correct 19 ms 10060 KB Output is correct
4 Correct 15 ms 10336 KB Output is correct
5 Correct 30 ms 12092 KB Output is correct
6 Correct 27 ms 12108 KB Output is correct
7 Correct 28 ms 12116 KB Output is correct
8 Correct 30 ms 12032 KB Output is correct
9 Incorrect 30 ms 12008 KB 1st lines differ - on the 1st token, expected: '99999', found: '66666'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 9956 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453'
2 Halted 0 ms 0 KB -