Submission #673231

# Submission time Handle Problem Language Result Execution time Memory
673231 2022-12-20T01:32:15 Z Hacv16 Jelly Flavours (IOI20_jelly) C++17
0 / 100
15 ms 21200 KB
#include <bits/stdc++.h>
#include "jelly.h"
using namespace std;
 
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
 
#define fr first
#define sc second

const int MAX = 2005;
const int INF = 0x3f3f3f3f;
int n, a[MAX], b[MAX];
 
int find_maximum_unique(int x, int y, vector<int> _a, vector<int> _b) {
	n = _a.size();
	
	vector<pair<int, int>> aux;

	for(int i = 0; i < n; i++)
		aux.emplace_back(_a[i], _b[i]);

	sort(aux.begin(), aux.end());

	vector<vector< pair<int, int> >> dp(n + 1, vector< pair<int, int> >(y + 1));

	dp[0][0] = {0, x};

	for(int t = 1; t <= y; t++)
        dp[0][t] = {-INF, -INF};

	int ans = 0;

	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= y; j++){
			dp[i][j] = dp[i - 1][j];

			if(dp[i][j].sc >= _a[i - 1]){
				dp[i][j].fr++;
				dp[i][j].sc -= a[i - 1];
			}

			if(j >= _b[i - 1]){
				pair<int, int> tmp = dp[i - 1][j - _b[i - 1]];
				tmp.fr++;

				if(tmp.fr > dp[i][j].fr || (tmp.fr == dp[i][j].fr && tmp.sc > dp[i][j].sc))
					dp[i][j] = tmp;
			}

			ans = max(ans, dp[i][j].fr);
		}
	}
 
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '8', found: '9'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '8', found: '9'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB 1st lines differ - on the 1st token, expected: '689', found: '1947'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 21200 KB 1st lines differ - on the 1st token, expected: '62', found: '1936'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 16980 KB 1st lines differ - on the 1st token, expected: '154', found: '1959'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '8', found: '9'
2 Halted 0 ms 0 KB -