답안 #684934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
684934 2023-01-22T21:21:54 Z Konti2 메기 농장 (IOI22_fish) C++17
52 / 100
1000 ms 294708 KB
#include <bits/stdc++.h>
#include "fish.h"

using namespace std;

using ll = long long;

ll t[3001][3001];
ll dp[3001][3001][2];
ll sum[3001][3001];

ll max_weights(int N, int M, vector<int> x, vector<int> y, vector<int> w){
	  ll ans = 0;
	  ll pop;
	  for (int i = 0; i < M; i++){
		  t[x[i]][y[i]] = w[i];
	  }
	  for (int i = 0; i < N; i++){
		  for (int h = 1; h <= N; h++){
			  sum[i][h] = t[i][h-1] + sum[i][h-1];
		  }
		  if (i){
			  // CASE 1 a >= b
			  dp[i][0][1] = dp[i-1][0][1];
			  ans = max(ans, dp[i][0][1]);
			  for (int a = 1; a <= N; a++){
				  dp[i][a][1] = max(dp[i-1][a][1], dp[i][a-1][1] + t[i-1][a-1]);
				  ans = max(ans, dp[i][a][1]);
			  }
			  // CASE 2 b >= a;
			  dp[i][N][0] = max(dp[i-1][N][0], dp[i-1][N][1]);
			  ans = max(ans, dp[i][N][0]);
			  for (int a = N-1; a >= 0; a--){
				  dp[i][a][0] = max(dp[i][a+1][0] + t[i][a], max(dp[i-1][a][0], dp[i-1][a][1]));
				   ans = max(ans, dp[i][a][0]);
			  }
			  if (i-1){
				// CASE 3 min(a,b,c) == b == 0 && a >= c
				dp[i][0][1] = max(dp[i][0][1], max(dp[i-2][0][1], dp[i-2][0][0]));
				ans = max(ans, dp[i][0][1]);
				for (int a = 1; a <= N; a++){
					dp[i][a][1] = max(dp[i][a][1], max(dp[i][a-1][1] + t[i-1][a-1], max(dp[i-2][a][0], dp[i-2][a][1]) + sum[i-1][a]));
					 ans = max(ans, dp[i][a][1]);
				}
				// CASE 4 min(a,b,c) == b == 0 && c >= a;
				dp[i][N][1] = max(dp[i][N][1], max(dp[i-2][N][1], dp[i-2][N][0]) + sum[i-1][N]);
				pop = max(dp[i-2][N][1], dp[i-2][N][0]) + sum[i-1][N];
				ans = max(ans, dp[i][N][1]);
				for (int a = N-1; a >= 0; a--){
					dp[i][a][1] = max(dp[i][a][1], max(pop, max(dp[i-2][a][0], dp[i-2][a][1]) + sum[i-1][a]));
					 pop = max(pop, max(dp[i-2][a][0], dp[i-2][a][1]) + sum[i-1][a]);
					 ans = max(ans, dp[i][a][1]);
				}
			}
		}
	}
			  
			  
						  
	  
	  return ans;
  }
	
/*
	
int main(){
	int n;
	cin >> n;
	int m;
	cin >> m;
	vector<int> x(m);
	vector<int> y(m);
	vector<int> w(m);
	for (int i = 0; i < m; i++){
		cin >> x[i];
		cin >> y[i];
		cin >> w[i];
	}
	cout << max_weights(n, m, x, y, w);
	return 0;
}

*/		  


# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 76460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 1093 ms 76108 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1096 ms 66896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 5 ms 6136 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 5 ms 6084 KB Output is correct
13 Correct 1 ms 1236 KB Output is correct
14 Correct 5 ms 6084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 5 ms 6136 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 5 ms 6084 KB Output is correct
13 Correct 1 ms 1236 KB Output is correct
14 Correct 5 ms 6084 KB Output is correct
15 Correct 4 ms 5972 KB Output is correct
16 Correct 2 ms 1220 KB Output is correct
17 Correct 16 ms 7892 KB Output is correct
18 Correct 16 ms 7612 KB Output is correct
19 Correct 15 ms 8140 KB Output is correct
20 Correct 17 ms 8256 KB Output is correct
21 Correct 15 ms 8140 KB Output is correct
22 Correct 27 ms 9720 KB Output is correct
23 Correct 6 ms 7048 KB Output is correct
24 Correct 12 ms 8020 KB Output is correct
25 Correct 4 ms 6100 KB Output is correct
26 Correct 6 ms 6612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 5 ms 6136 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 5 ms 6084 KB Output is correct
13 Correct 1 ms 1236 KB Output is correct
14 Correct 5 ms 6084 KB Output is correct
15 Correct 4 ms 5972 KB Output is correct
16 Correct 2 ms 1220 KB Output is correct
17 Correct 16 ms 7892 KB Output is correct
18 Correct 16 ms 7612 KB Output is correct
19 Correct 15 ms 8140 KB Output is correct
20 Correct 17 ms 8256 KB Output is correct
21 Correct 15 ms 8140 KB Output is correct
22 Correct 27 ms 9720 KB Output is correct
23 Correct 6 ms 7048 KB Output is correct
24 Correct 12 ms 8020 KB Output is correct
25 Correct 4 ms 6100 KB Output is correct
26 Correct 6 ms 6612 KB Output is correct
27 Correct 187 ms 223912 KB Output is correct
28 Correct 73 ms 31920 KB Output is correct
29 Correct 258 ms 227424 KB Output is correct
30 Correct 280 ms 270304 KB Output is correct
31 Correct 284 ms 270900 KB Output is correct
32 Correct 97 ms 28388 KB Output is correct
33 Correct 308 ms 294704 KB Output is correct
34 Correct 296 ms 294708 KB Output is correct
35 Correct 223 ms 231292 KB Output is correct
36 Correct 273 ms 240580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1096 ms 66896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 76460 KB Time limit exceeded
2 Halted 0 ms 0 KB -