답안 #724308

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724308 2023-04-15T04:36:58 Z ismayil 메기 농장 (IOI22_fish) C++17
18 / 100
87 ms 9960 KB
#pragma GCC optimize("O3")
#include "fish.h"
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll INF = 3e14 + 4; 
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
	int flag = 0;
	for(int i = 0; i < M; i++){
		if(X[i] > 1){
			flag = 1;
		}
	}
	if(flag){
		ll dp[N][2], a[N];
		memset(dp, 0, sizeof(dp)); memset(a, 0, sizeof(a));
		for(int i = 0; i < M; i++) a[X[i]] += W[i]; 
		dp[1][0] = a[1];
		dp[1][1] = a[0];
		for(int i = 2; i < N; i++){
			dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][0]);
			dp[i][1] = max(max(dp[i - 2][0] + a[i - 1], dp[i - 1][1]), dp[i - 2][1] + a[i - 1]);
		}
		return max(dp[N - 1][0], dp[N - 1][1]);
	}
	ll ans[N + 1][2];
	memset(ans, 0, sizeof(ans));
	for(int i = 0; i < M; i++){
		ans[Y[i] + 1][X[i]] = W[i];
	}
	for(int i = 1; i <= N; i++){
		ans[i][0] += ans[i - 1][0];
		ans[i][1] += ans[i - 1][1];
	}
	ll res = max(ans[N][0], ans[N][1]);
	if(N <= 2) return res;
	for (int i = 0; i <= N; i++)
	{
		res = max(res, ans[i][0] + (ans[N][1] - ans[i][1]));
	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 3976 KB Output is correct
2 Correct 35 ms 4540 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 2 ms 1748 KB Output is correct
5 Correct 87 ms 9956 KB Output is correct
6 Correct 87 ms 9960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 50 ms 8196 KB Output is correct
3 Correct 81 ms 8244 KB Output is correct
4 Correct 23 ms 4944 KB Output is correct
5 Correct 29 ms 5940 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 1 ms 1832 KB Output is correct
12 Correct 24 ms 4956 KB Output is correct
13 Correct 32 ms 5928 KB Output is correct
14 Correct 26 ms 4956 KB Output is correct
15 Correct 29 ms 5456 KB Output is correct
16 Correct 27 ms 4956 KB Output is correct
17 Correct 29 ms 5432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1836 KB Output is correct
2 Correct 3 ms 2644 KB Output is correct
3 Correct 17 ms 4052 KB Output is correct
4 Correct 12 ms 3788 KB Output is correct
5 Correct 30 ms 5716 KB Output is correct
6 Correct 22 ms 5284 KB Output is correct
7 Correct 28 ms 5584 KB Output is correct
8 Correct 30 ms 5784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 300 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 300 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 300 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1836 KB Output is correct
2 Correct 3 ms 2644 KB Output is correct
3 Correct 17 ms 4052 KB Output is correct
4 Correct 12 ms 3788 KB Output is correct
5 Correct 30 ms 5716 KB Output is correct
6 Correct 22 ms 5284 KB Output is correct
7 Correct 28 ms 5584 KB Output is correct
8 Correct 30 ms 5784 KB Output is correct
9 Incorrect 28 ms 5356 KB 1st lines differ - on the 1st token, expected: '99999', found: '66666'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 3976 KB Output is correct
2 Correct 35 ms 4540 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 2 ms 1748 KB Output is correct
5 Correct 87 ms 9956 KB Output is correct
6 Correct 87 ms 9960 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 50 ms 8196 KB Output is correct
9 Correct 81 ms 8244 KB Output is correct
10 Correct 23 ms 4944 KB Output is correct
11 Correct 29 ms 5940 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 296 KB Output is correct
16 Correct 1 ms 1748 KB Output is correct
17 Correct 1 ms 1832 KB Output is correct
18 Correct 24 ms 4956 KB Output is correct
19 Correct 32 ms 5928 KB Output is correct
20 Correct 26 ms 4956 KB Output is correct
21 Correct 29 ms 5456 KB Output is correct
22 Correct 27 ms 4956 KB Output is correct
23 Correct 29 ms 5432 KB Output is correct
24 Correct 1 ms 1836 KB Output is correct
25 Correct 3 ms 2644 KB Output is correct
26 Correct 17 ms 4052 KB Output is correct
27 Correct 12 ms 3788 KB Output is correct
28 Correct 30 ms 5716 KB Output is correct
29 Correct 22 ms 5284 KB Output is correct
30 Correct 28 ms 5584 KB Output is correct
31 Correct 30 ms 5784 KB Output is correct
32 Incorrect 1 ms 300 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
33 Halted 0 ms 0 KB -