Submission #712574

# Submission time Handle Problem Language Result Execution time Memory
712574 2023-03-19T07:39:02 Z josanneo22 Catfish Farm (IOI22_fish) C++17
18 / 100
85 ms 10852 KB
#include "fish.h"
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include <vector>
#define FOR(i,a,b) for(int i = a; i < b; i++)
typedef long long ll;
using namespace std;
ll sub1(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
	return accumulate(W.begin(), W.end(), 0LL);
}
ll sub2(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
	ll ans = 0;
	vector<ll>cs1(N + 1, 0), cs2(N + 1, 0);
	for (int i = 0; i < M; i++) {
		if (X[i] == 0)
			cs1[Y[i]] += W[i];
		else
			cs2[Y[i]] += W[i];
	}
	for (int i = 1; i < N; i++)
		cs1[i] += cs1[i - 1], cs2[i] += cs2[i - 1];
	ans = max(cs1[N - 1], cs2[N - 1]);
	if (N == 2) return ans;
	for (int i = 0; i < N; i++) {
		ll cur = cs2[N - 1];
		cur -= cs2[i];
		cur += cs1[i];
		ans = max(ans, cur);
	}
	return ans;
}
ll sub3(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
	vector<ll> A(N);
	FOR(i, 0, M) {
		A[X[i]] = W[i];
	}
	ll dp[N][2]; memset(dp, 0, sizeof(dp));
	if (N > 1) {
		dp[1][0] = A[1];
		dp[1][1] = A[0];
	}
	FOR(i, 2, N) {
		dp[i][0] = dp[i - 1][1] + A[i];
		dp[i][1] = max(max(dp[i - 1][1], dp[i - 1][0]), dp[i - 2][0] + A[i - 1]);
	}
	FOR(i, 0, M) {
		if (Y[i] > 0) {
			ll ans = 0; FOR(j, 0, M) ans += W[j];
			return ans;
		}
	}
	return max(dp[N - 1][0], dp[N - 1][1]);
}
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) {
	bool sb1 = true, sb2 = true, sb3 = true;
	for (int i = 0; i < M; i++) {
		if (X[i] % 2 == 1) sb1 = false;
		if (X[i] >= 2) sb2 = false;
		if (Y[i] != 0) sb3 = false;
	}
	if (sb1) return sub1(N, M, X, Y, W);
	else if (sb2) {
		return sub2(N, M, X, Y, W);
	}
	else if (sb3) {
		return sub3(N, M, X, Y, W);
	}
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:69:1: warning: control reaches end of non-void function [-Wreturn-type]
   69 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3028 KB Output is correct
2 Correct 27 ms 3792 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 83 ms 10852 KB Output is correct
6 Correct 85 ms 10732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 46 ms 7336 KB Output is correct
3 Correct 57 ms 8932 KB Output is correct
4 Correct 21 ms 3028 KB Output is correct
5 Correct 28 ms 3768 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 280 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 24 ms 4600 KB Output is correct
13 Correct 27 ms 5328 KB Output is correct
14 Correct 24 ms 4460 KB Output is correct
15 Correct 29 ms 4952 KB Output is correct
16 Correct 23 ms 4460 KB Output is correct
17 Correct 26 ms 4940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 19 ms 4280 KB Output is correct
4 Correct 12 ms 3924 KB Output is correct
5 Correct 29 ms 6100 KB Output is correct
6 Correct 21 ms 6096 KB Output is correct
7 Correct 26 ms 6084 KB Output is correct
8 Correct 28 ms 6092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '311850533155'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '311850533155'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '311850533155'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 19 ms 4280 KB Output is correct
4 Correct 12 ms 3924 KB Output is correct
5 Correct 29 ms 6100 KB Output is correct
6 Correct 21 ms 6096 KB Output is correct
7 Correct 26 ms 6084 KB Output is correct
8 Correct 28 ms 6092 KB Output is correct
9 Correct 26 ms 6092 KB Output is correct
10 Incorrect 27 ms 4944 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 22 ms 3028 KB Output is correct
2 Correct 27 ms 3792 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 83 ms 10852 KB Output is correct
6 Correct 85 ms 10732 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 46 ms 7336 KB Output is correct
9 Correct 57 ms 8932 KB Output is correct
10 Correct 21 ms 3028 KB Output is correct
11 Correct 28 ms 3768 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 280 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 24 ms 4600 KB Output is correct
19 Correct 27 ms 5328 KB Output is correct
20 Correct 24 ms 4460 KB Output is correct
21 Correct 29 ms 4952 KB Output is correct
22 Correct 23 ms 4460 KB Output is correct
23 Correct 26 ms 4940 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
26 Correct 19 ms 4280 KB Output is correct
27 Correct 12 ms 3924 KB Output is correct
28 Correct 29 ms 6100 KB Output is correct
29 Correct 21 ms 6096 KB Output is correct
30 Correct 26 ms 6084 KB Output is correct
31 Correct 28 ms 6092 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '311850533155'
41 Halted 0 ms 0 KB -