Submission #1080893

# Submission time Handle Problem Language Result Execution time Memory
1080893 2024-08-29T15:48:18 Z allin27x Catfish Farm (IOI22_fish) C++17
0 / 100
1000 ms 54548 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N= 305;
int dp[N][N][N];
int sfm[N];
int fs[N][9];

long long max_weights(signed n, signed m, std::vector<signed> x, std::vector<signed> y, std::vector<signed> w){
	for (int i=0; i<m; i++) fs[x[i]][y[i]] = w[i];

	for (int h0=0; h0<=n; h0++) {
		for (int h1=0; h1<=n; h1++) {
			if (h0 < h1) {
				for (int r = h0; r<h1; r++) dp[1][h0][h1] += fs[0][r];
			}
			if (h0 > h1) {
				for (int r = h1; r< h0; r++) dp[1][h0][h1] += fs[1][r];
			}
		}
	}

	for (int i=2; i<n; i++) {
		for (int h0=0; h0<=n; h0++) {
			int mm = 0; for (int t=0;  t<=h0; t++) mm = max(mm, dp[i-1][t][h0]);
			sfm[n] = dp[i-1][n][h0]; for (int j=n-1; j>=0; j--) sfm[j] = max(sfm[j+1], dp[i-1][j][h0]);
			int s = 0; for (int h=0; h<h0; h++) s += fs[i][h]; int s1 = 0;
			for (int h=0;  h<=h0; h++) {
				dp[i][h0][h] = max(dp[i][h0][h], s - s1 + sfm[0]); s1 += fs[i][h];
			}
			int mx = mm;
			for (int h= h0; h<=n; h++) {
				mx = max(mx + fs[i-1][h], dp[i-1][h+1][h0]);
				int r = max(mx, sfm[h+1]);
				dp[i][h0][h] = max(dp[i][h0][h], r);
			}

		}
	}
	// for (int i=0; i<=n; i++) {
	// 	for (int j=0; j<=n; j++) {
	// 		cout<<i<<' '<<j<<' '<<dp[3][i][j]<<'\n';
	// 	}
	// }
	int ans = 0;
	for (int h0=0; h0<=n; h0++) {
		for (int h1=0; h1<=n; h1++) {
			ans = max(ans, dp[n-1][h0][h1]);
		}
	}
	return ans;
}

# Verdict Execution time Memory Grader output
1 Execution timed out 1036 ms 5976 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Execution timed out 1090 ms 9128 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1004 ms 844 KB Time limit exceeded
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 604 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 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 35 ms 54548 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '3345547246916'
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 604 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 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 35 ms 54548 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '3345547246916'
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 604 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 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 35 ms 54548 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '3345547246916'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1004 ms 844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1036 ms 5976 KB Time limit exceeded
2 Halted 0 ms 0 KB -