Submission #871724

# Submission time Handle Problem Language Result Execution time Memory
871724 2023-11-11T11:50:10 Z Ludissey Catfish Farm (IOI22_fish) C++17
0 / 100
1000 ms 2097152 KB
#include "fish.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int>> a;
vector<vector<vector<int>>> memo;
int N,M;
int dp(int x, int last, int lastlast){
  if(memo[x][last][lastlast]!=-1) return memo[x][last][lastlast];
  if(x==N){
    int c=0;
    for (int y = last; y <= lastlast; y++) c+=a[x-1][y];
    return memo[x][last][lastlast]=c;
  }

  memo[x][last][lastlast] = 0;
  for (int i = 0; i < N; i++)
  {
    int c=dp(x+1, i, last);
    if(x>0) for (int y = last; y <= max(i,lastlast); y++) c+=a[x-1][y];
    memo[x][last][lastlast]=max(c, memo[x][last][lastlast]);
  }
  return memo[x][last][lastlast];
}

long long max_weights(signed n, signed m, std::vector<signed> X, std::vector<signed> Y, std::vector<signed> W) {
  N=n; M=m; 
  a.resize(N, vector<int>(N,0));
  memo.resize(N+1, vector<vector<int>>(N+1, vector<int>(N+1,-1)));
  for (int i = 0; i < M; i++){
    a[X[i]][Y[i]] = W[i];
  }
  int p=dp(0,0,0);
  return p;
}
# Verdict Execution time Memory Grader output
1 Runtime error 799 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 788 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 740 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 376 KB Output is correct
9 Execution timed out 1087 ms 28288 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 376 KB Output is correct
9 Execution timed out 1087 ms 28288 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 376 KB Output is correct
9 Execution timed out 1087 ms 28288 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 740 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 799 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -