Submission #627256

# Submission time Handle Problem Language Result Execution time Memory
627256 2022-08-12T11:44:34 Z coloboxx Catfish Farm (IOI22_fish) C++17
12 / 100
91 ms 9676 KB
#include "fish.h"
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int MAXN = 300064;

ll a[MAXN], dp[MAXN][2];

ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
	for (int i = 0; i < M; ++i)
		a[X[i] + 1] = W[i];

	for (int i = 2; i <= N; ++i) {
		dp[i][0] = max(dp[i - 1][0], dp[i - 1][1] + a[i]);
		dp[i][1] = dp[i - 1][1];

		if (i > 2) dp[i][1] = max({ dp[i][1], dp[i - 2][0] + a[i - 1], dp[i - 2][1] + a[i - 1] });
		else dp[i][1] = max(dp[i][1], a[i - 1]);
	}

	ll ans = 0;
	for (int i = 1; i <= N; ++i)
		ans = max({ ans, dp[i][0], dp[i][1] });
	
	return (*max_element(Y.begin(), Y.end()) ? accumulate(W.begin(), W.end(), 0ll) : ans);
}
# Verdict Execution time Memory Grader output
1 Correct 27 ms 3560 KB Output is correct
2 Correct 31 ms 4164 KB Output is correct
3 Correct 2 ms 1876 KB Output is correct
4 Correct 2 ms 1876 KB Output is correct
5 Correct 91 ms 8824 KB Output is correct
6 Correct 89 ms 9676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 52 ms 8208 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 17 ms 3640 KB Output is correct
4 Correct 13 ms 3156 KB Output is correct
5 Correct 30 ms 4948 KB Output is correct
6 Correct 24 ms 4952 KB Output is correct
7 Correct 47 ms 4924 KB Output is correct
8 Correct 31 ms 4932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '4044', found: '6066'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '4044', found: '6066'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '4044', found: '6066'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 17 ms 3640 KB Output is correct
4 Correct 13 ms 3156 KB Output is correct
5 Correct 30 ms 4948 KB Output is correct
6 Correct 24 ms 4952 KB Output is correct
7 Correct 47 ms 4924 KB Output is correct
8 Correct 31 ms 4932 KB Output is correct
9 Correct 28 ms 4984 KB Output is correct
10 Incorrect 30 ms 4984 KB 1st lines differ - on the 1st token, expected: '36454348383152', found: '49943314382825'
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 3560 KB Output is correct
2 Correct 31 ms 4164 KB Output is correct
3 Correct 2 ms 1876 KB Output is correct
4 Correct 2 ms 1876 KB Output is correct
5 Correct 91 ms 8824 KB Output is correct
6 Correct 89 ms 9676 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Incorrect 52 ms 8208 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025'
9 Halted 0 ms 0 KB -