Submission #828563

# Submission time Handle Problem Language Result Execution time Memory
828563 2023-08-17T11:18:42 Z ttamx Catfish Farm (IOI22_fish) C++17
52 / 100
724 ms 224400 KB
#include "fish.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=3005;
const ll inf=1e18;

int n,m;
ll w[N][N];
ll dp[N][N][2];
ll suff[N];
ll val[N];

long long max_weights(int _n,int _m,vector<int> X,vector<int> Y,vector<int> W) {
	n=_n,m=_m;
	for(int i=0;i<m;i++)w[X[i]+1][Y[i]+1]=W[i];
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)w[i][j]+=w[i][j-1];
	for(int i=1;i<=n;i++)for(int j=0;j<=n;j++)dp[i][j][0]=dp[i][j][1]=-inf;
	for(int i=1;i<=n;i++){
		if(i>=2)for(int j=n;j>=0;j--)suff[j]=max(suff[j+1],dp[i-2][j][1]);
		ll tmp=-inf,tmp2=-inf;
		for(int j=0;j<=n;j++){
			tmp=max(tmp,dp[i-1][j][0]-w[i][j]-w[i-1][j]);
			dp[i][j][0]=w[i-1][j]+tmp+w[i+1][j];
			if(i>=2){
				tmp2=max(tmp2,dp[i-2][j][0]-w[i-1][j]);
				dp[i][j][0]=max(dp[i][j][0],w[i-1][j]+tmp+w[i+1][j]);
				dp[i][j][0]=max(dp[i][j][0],suff[j]+w[i+1][j]);
			}
		}
		tmp=-inf;
		for(int j=n;j>=0;j--){
			tmp=max(tmp,dp[i-1][j][1]);
			dp[i][j][1]=tmp-w[i][j]+w[i+1][j];
			dp[i][j][1]=max(dp[i][j][1],dp[i][j][0]);
		}
	}
	ll ans=0;
	for(int i=0;i<=n;i++)ans=max(ans,dp[n][i][1]);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 706 ms 148912 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Runtime error 713 ms 153364 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 724 ms 143592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 308 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 2 ms 2004 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 2 ms 2004 KB Output is correct
12 Correct 3 ms 4820 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 3 ms 4820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 308 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 2 ms 2004 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 2 ms 2004 KB Output is correct
12 Correct 3 ms 4820 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 3 ms 4820 KB Output is correct
15 Correct 3 ms 4820 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 14 ms 6608 KB Output is correct
18 Correct 13 ms 6612 KB Output is correct
19 Correct 13 ms 6624 KB Output is correct
20 Correct 12 ms 6592 KB Output is correct
21 Correct 13 ms 6600 KB Output is correct
22 Correct 23 ms 8388 KB Output is correct
23 Correct 5 ms 5204 KB Output is correct
24 Correct 9 ms 5952 KB Output is correct
25 Correct 3 ms 4816 KB Output is correct
26 Correct 5 ms 5204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 308 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 2 ms 2004 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 2 ms 2004 KB Output is correct
12 Correct 3 ms 4820 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 3 ms 4820 KB Output is correct
15 Correct 3 ms 4820 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 14 ms 6608 KB Output is correct
18 Correct 13 ms 6612 KB Output is correct
19 Correct 13 ms 6624 KB Output is correct
20 Correct 12 ms 6592 KB Output is correct
21 Correct 13 ms 6600 KB Output is correct
22 Correct 23 ms 8388 KB Output is correct
23 Correct 5 ms 5204 KB Output is correct
24 Correct 9 ms 5952 KB Output is correct
25 Correct 3 ms 4816 KB Output is correct
26 Correct 5 ms 5204 KB Output is correct
27 Correct 126 ms 212128 KB Output is correct
28 Correct 59 ms 28308 KB Output is correct
29 Correct 195 ms 224340 KB Output is correct
30 Correct 200 ms 224232 KB Output is correct
31 Correct 204 ms 224400 KB Output is correct
32 Correct 72 ms 23884 KB Output is correct
33 Correct 199 ms 224336 KB Output is correct
34 Correct 201 ms 224328 KB Output is correct
35 Correct 160 ms 216768 KB Output is correct
36 Correct 192 ms 224312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 724 ms 143592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 706 ms 148912 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -