Submission #686421

# Submission time Handle Problem Language Result Execution time Memory
686421 2023-01-25T09:13:05 Z acceptify Catfish Farm (IOI22_fish) C++17
0 / 100
56 ms 12432 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll mxn = 305;
const ll mxm = 3e5 + 5;

ll n, m, w[mxn][mxn], dp[mxn][mxn][mxn], c[2][mxn], res = 0;

ll 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];
	auto get = [](int i, int jl, int jr) -> ll {
		if (jl > jr) return 0;
		return w[i][jr] - (jl ? w[i][jl - 1] : 0);
	};
	for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) {
		if (i >= j) dp[2][i][j] = 0;
		else dp[2][i][j] = get(1, i + 1, j);
	}
	for (int i = 3; i <= n; i++) for (int j = 0; j <= n; j++) {
		for (int k = 0; k <= n; k++) {
			c[0][k] = dp[i - 1][k][j];
			c[1][k] = dp[i - 1][k][j] + get(i - 1, j + 1, k);
		}
		for (int k = 1; k <= n; k++) c[0][k] = max(c[0][k], c[0][k - 1]);
		for (int k = n - 1; k >= 0; k--) c[1][k] = max(c[1][k], c[1][k + 1]);
		for (int k = 0; k < j; k++) dp[i][j][k] = c[0][n];
		for (int k = j; k <= n; k++) dp[i][j][k] = max(c[0][k] + get(i - 1, j + 1, k), c[1][k]);
	}
	for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) res = max(res, dp[n][i][j] + (i > j ? get(n, j + 1, i) : 0));
	return res;
}
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 7080 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 56 ms 12432 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1864 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1864 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 7080 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -