Submission #1077188

# Submission time Handle Problem Language Result Execution time Memory
1077188 2024-08-27T02:41:44 Z pcc Catfish Farm (IOI22_fish) C++17
14 / 100
1000 ms 13364 KB
#include "fish.h"

#include <vector>
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fs first
#define sc second

const ll inf = 1e18;
const int mxn = 330;
ll dp[mxn][mxn][2];
vector<pii> fish[mxn];

ll f(int idx,int s,int e){
	ll re = 0;
	for(auto &[pos,w]:fish[idx]){
		if(pos>s&&pos<=e)re += w;
	}
	return re;
}

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
	for(int i = 0;i<M;i++){
		fish[X[i]].push_back(pii(Y[i],W[i]));
	}
	for(int i = 0;i<N;i++)sort(fish[i].begin(),fish[i].end());
	for(int i = 0;i<N;i++){
		dp[0][i][0] = f(1,-1,i);
	}
	ll big = 0;
	for(int i = 1;i<N;i++){
		for(int h = 0;h<N;h++){
			for(int j = 0;j<N;j++){
				if(j<h){
					dp[i][h][0] = max(dp[i][h][0],dp[i-1][j][0]-f(i,-1,j)+f(i-1,j,h)+f(i+1,-1,h));
				}
				else{
					dp[i][h][1] = max(dp[i][h][1],max(dp[i-1][j][0],dp[i-1][j][1])-f(i,-1,h)+f(i+1,-1,h));
				}
				if(i-2>=0)dp[i][h][0] = max(dp[i][h][0],max(dp[i-2][j][0],dp[i-2][j][1])+f(i-1,j,h)+f(i+1,-1,h));
			}
			dp[i][h][0] = max(dp[i][h][0],big+f(i-1,-1,h)+f(i+1,-1,h));
		}
		if(i-2>=0){
			for(int j = 0;j<N;j++)big = max({big,dp[i-2][j][0],dp[i-2][j][1]});
		}
	}
	ll ans = 0;

	/*
	for(int i = 0;i<N;i++){
		for(int j = 0;j<N;j++)cerr<<dp[i][j][0]<<','<<dp[i][j][1]<<' ';cerr<<endl;
	}cerr<<endl;
	*/

	for(int i = 0;i<N;i++){
		for(int j = 0;j<N;j++)ans = max({ans,dp[i][j][0],dp[i][j][1]});
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 7376 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 47 ms 13364 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 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 456 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 52 ms 1120 KB Output is correct
10 Correct 631 ms 1936 KB Output is correct
11 Correct 55 ms 1104 KB Output is correct
12 Correct 326 ms 1872 KB Output is correct
13 Correct 7 ms 604 KB Output is correct
14 Correct 291 ms 1864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 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 456 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 52 ms 1120 KB Output is correct
10 Correct 631 ms 1936 KB Output is correct
11 Correct 55 ms 1104 KB Output is correct
12 Correct 326 ms 1872 KB Output is correct
13 Correct 7 ms 604 KB Output is correct
14 Correct 291 ms 1864 KB Output is correct
15 Correct 146 ms 1876 KB Output is correct
16 Correct 38 ms 924 KB Output is correct
17 Execution timed out 1050 ms 2876 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 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 456 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 52 ms 1120 KB Output is correct
10 Correct 631 ms 1936 KB Output is correct
11 Correct 55 ms 1104 KB Output is correct
12 Correct 326 ms 1872 KB Output is correct
13 Correct 7 ms 604 KB Output is correct
14 Correct 291 ms 1864 KB Output is correct
15 Correct 146 ms 1876 KB Output is correct
16 Correct 38 ms 924 KB Output is correct
17 Execution timed out 1050 ms 2876 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 7376 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -