Submission #1074066

# Submission time Handle Problem Language Result Execution time Memory
1074066 2024-08-25T07:32:33 Z Gromp15 Catfish Farm (IOI22_fish) C++17
26 / 100
1000 ms 2097152 KB
#include <bits/stdc++.h>
#include "fish.h"
#define ll long long
#define ar array
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
using namespace std;

const ll INF = 1e18;
template<typename T> bool ckmin(T &a, const T &b ) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b ) { return a < b ? a = b, 1 : 0; }

long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y, std::vector<int> w) {
	vector<vector<ar<ll, 2>>> each(n);
	for (int i = 0; i < m; i++) {
		each[x[i]].push_back({y[i], w[i]});
		each[x[i]].push_back({y[i]-1, 0});
	}
	for (int i = 0; i < n; i++) each[i].push_back({n-1, 0}), each[i].push_back({-1, 0});
	for (int i = 0; i < n; i++) {
		sort(all(each[i]));
		vector<ar<ll, 2>> nw;
		ll s = 0;
		for (int j = 0; j < sz(each[i]); j++) {
			int r = j;
			while (r+1 < sz(each[i]) && each[i][r+1][0] == each[i][r][0]) r++;
			for (int k = j; k <= r; k++) s += each[i][k][1];
			nw.push_back({each[i][j][0], s});
			j = r;
		}
		swap(each[i], nw);
	}
	vector<vector<ll>> dp;
	auto query = [&](int pos, int x) {
		return (*prev(upper_bound(all(each[pos]), ar<ll, 2>{x, LLONG_MAX})))[1];
	};
	for (int i = 0; i < n; i++) {
		vector<vector<ll>> dp2;
		const int N = sz(each[i]);
		dp2.resize(i ? sz(each[i-1]) : 1, vector<ll>(N, -INF));
		if (!i) {
			for (int j = 0; j < N; j++) {
				dp2[0][j] = query(i+1, each[i][j][0]);
			}
			swap(dp, dp2);
		}
		else {
			for (int j = 0; j < sz(dp); j++) {
				for (int k = 0; k < sz(dp[j]); k++) {
					for (int l = 0; l < N; l++) {
						ckmax(dp2[k][l], dp[j][k] + query(i-1, each[i][l][0]) + (i+1 < n ? query(i+1, each[i][l][0]) : 0) - query(i-1, min(i-2 >= 0 ? each[i-2][j][0] : -1, each[i][l][0])) - query(i-1, min(each[i-1][k][0], each[i][l][0])) - query(i, min(each[i-1][k][0], each[i][l][0])));
					}
				}
			}
			swap(dp, dp2);
		}
	}
	ll ans = -INF;
	for (auto x : dp) for (auto z : x) ckmax(ans, z);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 97 ms 16872 KB Output is correct
2 Correct 110 ms 19312 KB Output is correct
3 Correct 37 ms 7260 KB Output is correct
4 Correct 40 ms 7260 KB Output is correct
5 Correct 399 ms 33900 KB Output is correct
6 Correct 779 ms 34532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 960 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 7260 KB Output is correct
2 Correct 38 ms 7260 KB Output is correct
3 Correct 90 ms 11100 KB Output is correct
4 Correct 70 ms 10076 KB Output is correct
5 Correct 126 ms 15696 KB Output is correct
6 Correct 129 ms 14932 KB Output is correct
7 Correct 140 ms 15936 KB Output is correct
8 Correct 140 ms 15696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 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 Correct 2 ms 344 KB Output is correct
10 Correct 12 ms 720 KB Output is correct
11 Correct 5 ms 440 KB Output is correct
12 Correct 13 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 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 Correct 2 ms 344 KB Output is correct
10 Correct 12 ms 720 KB Output is correct
11 Correct 5 ms 440 KB Output is correct
12 Correct 13 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 868 ms 960 KB Output is correct
17 Execution timed out 1063 ms 5212 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 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 Correct 2 ms 344 KB Output is correct
10 Correct 12 ms 720 KB Output is correct
11 Correct 5 ms 440 KB Output is correct
12 Correct 13 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 868 ms 960 KB Output is correct
17 Execution timed out 1063 ms 5212 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 7260 KB Output is correct
2 Correct 38 ms 7260 KB Output is correct
3 Correct 90 ms 11100 KB Output is correct
4 Correct 70 ms 10076 KB Output is correct
5 Correct 126 ms 15696 KB Output is correct
6 Correct 129 ms 14932 KB Output is correct
7 Correct 140 ms 15936 KB Output is correct
8 Correct 140 ms 15696 KB Output is correct
9 Correct 259 ms 15528 KB Output is correct
10 Incorrect 141 ms 13656 KB 1st lines differ - on the 1st token, expected: '36454348383152', found: '36452622569448'
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 97 ms 16872 KB Output is correct
2 Correct 110 ms 19312 KB Output is correct
3 Correct 37 ms 7260 KB Output is correct
4 Correct 40 ms 7260 KB Output is correct
5 Correct 399 ms 33900 KB Output is correct
6 Correct 779 ms 34532 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Runtime error 960 ms 2097152 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -