Submission #889183

# Submission time Handle Problem Language Result Execution time Memory
889183 2023-12-19T06:51:18 Z kim Catfish Farm (IOI22_fish) C++17
35 / 100
327 ms 17424 KB
#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int N,M;
int X[300005],Y[300005],W[300005];
int W2[305][305];
ll qs[305][305],dp[305][305][3];

long long max_weights(int N_, int M_, std::vector<int> X_, std::vector<int> Y_,
                      std::vector<int> W_) {
  N=N_,M=M_;
  for(int i=1;i<=M;++i) X[i]=X_[i-1]+1,Y[i]=Y_[i-1]+1,W[i]=W_[i-1];

  for(int i=1;i<=M;++i) W2[X[i]][Y[i]]=W[i];
  for(int i=1;i<=N;++i) for(int j=1;j<=N;++j) qs[i][j]=qs[i][j-1]+W2[i][j];

  for(int i=1;i<=N;++i) dp[0][i][0]=dp[0][i][1]=-1e18;

  for(int i=1;i<=N+1;++i){
    for(int j=0;j<=N;++j){
      for(int k=0;k<j;++k){
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][0]+qs[i-1][j]-qs[i-1][k]);
        if(i>3) dp[i][j][0]=max(dp[i][j][0],dp[i-2][k][0]+qs[i-1][j]),
                dp[i][j][0]=max(dp[i][j][0],dp[i-2][k][1]+qs[i-1][j]);
      }
      for(int k=j;k<=N;++k){
        dp[i][j][1]=max(dp[i][j][1],dp[i-1][k][1]+qs[i][k]-qs[i][j]);
        dp[i][j][1]=max(dp[i][j][1],dp[i-1][k][0]+qs[i][k]-qs[i][j]);
        if(i>2) dp[i][j][1]=max(dp[i][j][1],dp[i-2][k][1]+qs[i-1][k]),
                dp[i][j][1]=max(dp[i][j][1],dp[i-2][k][0]+qs[i-1][k]);
      }
    }
  }
  return dp[N+1][0][1];

}
# Verdict Execution time Memory Grader output
1 Runtime error 313 ms 13652 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Runtime error 327 ms 17424 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 315 ms 9692 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 9 ms 5696 KB Output is correct
10 Correct 65 ms 6780 KB Output is correct
11 Correct 9 ms 5464 KB Output is correct
12 Correct 68 ms 6992 KB Output is correct
13 Correct 2 ms 4952 KB Output is correct
14 Correct 78 ms 6740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 9 ms 5696 KB Output is correct
10 Correct 65 ms 6780 KB Output is correct
11 Correct 9 ms 5464 KB Output is correct
12 Correct 68 ms 6992 KB Output is correct
13 Correct 2 ms 4952 KB Output is correct
14 Correct 78 ms 6740 KB Output is correct
15 Correct 64 ms 6544 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
17 Correct 74 ms 8528 KB Output is correct
18 Correct 74 ms 8528 KB Output is correct
19 Correct 74 ms 8528 KB Output is correct
20 Correct 79 ms 8372 KB Output is correct
21 Correct 74 ms 8360 KB Output is correct
22 Correct 90 ms 10120 KB Output is correct
23 Correct 66 ms 6944 KB Output is correct
24 Correct 81 ms 7780 KB Output is correct
25 Correct 64 ms 6740 KB Output is correct
26 Correct 66 ms 6992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 9 ms 5696 KB Output is correct
10 Correct 65 ms 6780 KB Output is correct
11 Correct 9 ms 5464 KB Output is correct
12 Correct 68 ms 6992 KB Output is correct
13 Correct 2 ms 4952 KB Output is correct
14 Correct 78 ms 6740 KB Output is correct
15 Correct 64 ms 6544 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
17 Correct 74 ms 8528 KB Output is correct
18 Correct 74 ms 8528 KB Output is correct
19 Correct 74 ms 8528 KB Output is correct
20 Correct 79 ms 8372 KB Output is correct
21 Correct 74 ms 8360 KB Output is correct
22 Correct 90 ms 10120 KB Output is correct
23 Correct 66 ms 6944 KB Output is correct
24 Correct 81 ms 7780 KB Output is correct
25 Correct 64 ms 6740 KB Output is correct
26 Correct 66 ms 6992 KB Output is correct
27 Runtime error 17 ms 9932 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 315 ms 9692 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 313 ms 13652 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -