Submission #1055847

# Submission time Handle Problem Language Result Execution time Memory
1055847 2024-08-13T06:00:16 Z pawned Catfish Farm (IOI22_fish) C++17
12 / 100
50 ms 20304 KB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")

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

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;

#include "fish.h"

ll max_weights(int N, int M, vector<int> X_g, vector<int> Y_g, vector<int> W_g) {
	vi a(N);
	for (int i = 0; i < M; i++) {
		a[X_g[i]] += W_g[i];
	}
/*	cout<<"a: ";
	for (ll x : a)
		cout<<x<<" ";
	cout<<endl;*/
	vector<vi> dp(N + 1, vi(2, 0));
	// dp[i][j]: max sum till i, exclusive; j = 0 if no pier, j = 1 if has
	dp[0][1] = -1e18;
	for (int i = 1; i <= N; i++) {
		// a[i - 1] is empty
		dp[i][0] = dp[i - 1][0];
		dp[i][0] = max(dp[i][0], dp[i - 1][1] + a[i - 1]);
		// a[i - 1] is filled
		dp[i][1] = dp[i - 1][1];	// left also filled
		if (i >= 2)
			dp[i][1] = max(dp[i][1], max(dp[i - 2][0], dp[i - 2][1]) + a[i - 2]);
	}
/*	cout<<"dp: "<<endl;
	for (vi v : dp) {
		for (ll x : v)
			cout<<x<<" ";
		cout<<endl;
	}*/
	return max(dp[N][0], dp[N][1]);
}

// subtasks 1, 2: greedy
// subtask 3: dp

// code subtask 3 first to verify correct dp
# Verdict Execution time Memory Grader output
1 Correct 16 ms 9300 KB Output is correct
2 Correct 18 ms 10580 KB Output is correct
3 Correct 4 ms 6488 KB Output is correct
4 Correct 4 ms 6492 KB Output is correct
5 Correct 49 ms 20056 KB Output is correct
6 Correct 50 ms 20304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6492 KB Output is correct
2 Correct 4 ms 6492 KB Output is correct
3 Correct 14 ms 8112 KB Output is correct
4 Correct 10 ms 8028 KB Output is correct
5 Correct 18 ms 10472 KB Output is correct
6 Correct 16 ms 9820 KB Output is correct
7 Correct 18 ms 10588 KB Output is correct
8 Correct 18 ms 10580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6492 KB Output is correct
2 Correct 4 ms 6492 KB Output is correct
3 Correct 14 ms 8112 KB Output is correct
4 Correct 10 ms 8028 KB Output is correct
5 Correct 18 ms 10472 KB Output is correct
6 Correct 16 ms 9820 KB Output is correct
7 Correct 18 ms 10588 KB Output is correct
8 Correct 18 ms 10580 KB Output is correct
9 Incorrect 17 ms 10176 KB 1st lines differ - on the 1st token, expected: '99999', found: '66666'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 9300 KB Output is correct
2 Correct 18 ms 10580 KB Output is correct
3 Correct 4 ms 6488 KB Output is correct
4 Correct 4 ms 6492 KB Output is correct
5 Correct 49 ms 20056 KB Output is correct
6 Correct 50 ms 20304 KB Output is correct
7 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
8 Halted 0 ms 0 KB -