답안 #871733

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871733 2023-11-11T12:00:33 Z Ludissey 메기 농장 (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++)
  {
    if(i>0&&x>0&&a[x-1][i]==0&&(x<N-1&&&a[x+1][i]==0)) continue;
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 904 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 500 KB Output is correct
2 Runtime error 800 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 772 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 348 KB Output is correct
9 Execution timed out 1097 ms 28252 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 348 KB Output is correct
9 Execution timed out 1097 ms 28252 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 348 KB Output is correct
9 Execution timed out 1097 ms 28252 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 772 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 904 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -