답안 #1025499

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1025499 2024-07-17T05:35:41 Z TheWilp Jelly Flavours (IOI20_jelly) C++14
14 / 100
75 ms 856 KB
#include "jelly.h"
#include <vector>
#include <algorithm>
#include <map>

const int MAXMONEY = 10005;

class name{
public:
	int x;
	int y;
	bool operator<(const name& other) const{
		return x < other.x;
	}
};

class node{
public:
	int value;
	int count;
	node* left = nullptr;
	node* right = nullptr;
};

int get_mid(int left,int right) {
	return (right - left) / 2 + left;
}

int get_value(node* root) {
	if(!root) return 0;
	return root->value;
}

int get_count(node* root) {
	if(!root) return 0;
	return root->count;
}

void add(node* root,int pos,int value,int left = 0,int right = MAXMONEY) {
	if(right == left) {
		root->value = value;
		root->count = 1;
		return;
	}
	int mid = get_mid(left,right);
	if(pos <= mid) {
		if(root->left == nullptr) root->left = new node();
		add(root->left,pos,value,left,mid);
	}
	else {
		if(root->right == nullptr) root->right = new node();
		add(root->right,pos,value,mid + 1,right);
	}
	root->value = get_value(root->left) + get_value(root->right);
	root->count = get_count(root->left) + get_count(root->right);
}

int get_max_count(node* root,int max_value,int left = 0,int right = MAXMONEY) {
	if(!root) return 0;
	int mid = get_mid(left,right);
	if(max_value >= get_value(root->left)) {
		return get_count(root->left) + get_max_count(root->right,max_value - get_value(root->left),mid + 1,right);
	}
	else {
		return get_max_count(root->left,max_value,left,mid);
	}
}

int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
	int N = a.size();
	int ans = 0;
	std::vector<name> v(N);
	for(int q = 0;q < N;q++) {
		v[q].x = a[q];
		v[q].y = b[q];
	}
	std::sort(v.begin(),v.end());
	std::vector<int> dp(MAXMONEY,20000);
	dp[0] = 0;
	std::vector<int> res(N,20000);
	int min_require = 0;
	for(int q = 0;q < N;q++) {
		min_require += v[q].x;
		for(int w = MAXMONEY - 1;w>=0;w--) {
			if(w < v[q].x) break;
			dp[w] = std::min(dp[w],dp[w - v[q].x] + v[q].y);
		}
		for(int w = std::max(0,min_require - x);w < MAXMONEY;w++) {
			if(dp[w] <= y) {
				res[q] = std::min(res[q],dp[w]);
			}
		}
	}
	if(res.back() <= y) return N;

	std::vector<name> u(N);
	for(int q = 0;q < N;q++) {
		u[q].x = v[q].y;
		u[q].y = q;
	}
	std::sort(u.begin(),u.end());
	std::map<int,int> mm;
	for(int q = 0;q < N;q++) {
		mm[u[q].y] = q;
	}
	
	node* root = new node();
	for(int q = N - 1;q>=1;q--) {
		add(root,mm[q],v[q].x);
		if(res[q - 1] <= y) {
			int remain_value = y - res[q];
			ans = std::max(ans,q + get_max_count(root,remain_value));
		}
	}
	add(root,mm[0],v[0].x);
	ans = std::max(ans,get_max_count(root,y));

	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 600 KB 1st lines differ - on the 1st token, expected: '689', found: '65'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 604 KB Output is correct
2 Correct 20 ms 604 KB Output is correct
3 Correct 12 ms 604 KB Output is correct
4 Correct 46 ms 504 KB Output is correct
5 Correct 50 ms 348 KB Output is correct
6 Correct 12 ms 600 KB Output is correct
7 Correct 12 ms 604 KB Output is correct
8 Correct 11 ms 600 KB Output is correct
9 Correct 46 ms 348 KB Output is correct
10 Correct 47 ms 348 KB Output is correct
11 Incorrect 21 ms 500 KB 1st lines differ - on the 1st token, expected: '63', found: '87'
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 592 KB Output is correct
2 Correct 13 ms 616 KB Output is correct
3 Correct 16 ms 604 KB Output is correct
4 Correct 47 ms 488 KB Output is correct
5 Correct 45 ms 596 KB Output is correct
6 Correct 14 ms 604 KB Output is correct
7 Correct 13 ms 604 KB Output is correct
8 Correct 12 ms 516 KB Output is correct
9 Correct 47 ms 344 KB Output is correct
10 Correct 48 ms 344 KB Output is correct
11 Correct 21 ms 600 KB Output is correct
12 Correct 32 ms 488 KB Output is correct
13 Correct 18 ms 508 KB Output is correct
14 Correct 31 ms 492 KB Output is correct
15 Correct 36 ms 512 KB Output is correct
16 Correct 23 ms 512 KB Output is correct
17 Correct 27 ms 596 KB Output is correct
18 Correct 19 ms 596 KB Output is correct
19 Correct 34 ms 504 KB Output is correct
20 Correct 36 ms 604 KB Output is correct
21 Correct 24 ms 592 KB Output is correct
22 Correct 13 ms 604 KB Output is correct
23 Correct 12 ms 512 KB Output is correct
24 Correct 58 ms 488 KB Output is correct
25 Correct 45 ms 504 KB Output is correct
26 Correct 12 ms 600 KB Output is correct
27 Correct 13 ms 512 KB Output is correct
28 Correct 12 ms 604 KB Output is correct
29 Correct 47 ms 488 KB Output is correct
30 Correct 48 ms 344 KB Output is correct
31 Correct 21 ms 604 KB Output is correct
32 Correct 32 ms 504 KB Output is correct
33 Correct 18 ms 600 KB Output is correct
34 Correct 32 ms 592 KB Output is correct
35 Correct 35 ms 348 KB Output is correct
36 Correct 19 ms 604 KB Output is correct
37 Correct 19 ms 604 KB Output is correct
38 Correct 19 ms 604 KB Output is correct
39 Correct 36 ms 600 KB Output is correct
40 Correct 34 ms 604 KB Output is correct
41 Correct 20 ms 604 KB Output is correct
42 Correct 12 ms 604 KB Output is correct
43 Correct 13 ms 604 KB Output is correct
44 Correct 47 ms 348 KB Output is correct
45 Correct 45 ms 604 KB Output is correct
46 Correct 12 ms 604 KB Output is correct
47 Correct 12 ms 604 KB Output is correct
48 Correct 12 ms 508 KB Output is correct
49 Correct 47 ms 348 KB Output is correct
50 Correct 49 ms 740 KB Output is correct
51 Correct 21 ms 512 KB Output is correct
52 Correct 34 ms 596 KB Output is correct
53 Correct 22 ms 520 KB Output is correct
54 Correct 32 ms 500 KB Output is correct
55 Correct 35 ms 512 KB Output is correct
56 Correct 19 ms 604 KB Output is correct
57 Correct 19 ms 512 KB Output is correct
58 Correct 19 ms 604 KB Output is correct
59 Correct 34 ms 596 KB Output is correct
60 Correct 34 ms 592 KB Output is correct
61 Correct 20 ms 600 KB Output is correct
62 Correct 12 ms 600 KB Output is correct
63 Correct 12 ms 512 KB Output is correct
64 Correct 47 ms 348 KB Output is correct
65 Correct 45 ms 504 KB Output is correct
66 Correct 12 ms 604 KB Output is correct
67 Correct 12 ms 512 KB Output is correct
68 Correct 12 ms 604 KB Output is correct
69 Correct 47 ms 348 KB Output is correct
70 Correct 48 ms 344 KB Output is correct
71 Correct 20 ms 600 KB Output is correct
72 Correct 31 ms 504 KB Output is correct
73 Correct 18 ms 600 KB Output is correct
74 Correct 47 ms 592 KB Output is correct
75 Correct 36 ms 348 KB Output is correct
76 Correct 19 ms 856 KB Output is correct
77 Correct 20 ms 508 KB Output is correct
78 Correct 36 ms 596 KB Output is correct
79 Correct 42 ms 592 KB Output is correct
80 Correct 35 ms 596 KB Output is correct
81 Correct 25 ms 604 KB Output is correct
82 Correct 13 ms 604 KB Output is correct
83 Correct 13 ms 600 KB Output is correct
84 Correct 47 ms 344 KB Output is correct
85 Correct 67 ms 592 KB Output is correct
86 Correct 12 ms 600 KB Output is correct
87 Correct 15 ms 604 KB Output is correct
88 Correct 21 ms 604 KB Output is correct
89 Correct 75 ms 492 KB Output is correct
90 Correct 49 ms 344 KB Output is correct
91 Correct 20 ms 604 KB Output is correct
92 Correct 41 ms 592 KB Output is correct
93 Correct 18 ms 604 KB Output is correct
94 Correct 32 ms 504 KB Output is correct
95 Correct 40 ms 348 KB Output is correct
96 Correct 25 ms 604 KB Output is correct
97 Correct 19 ms 508 KB Output is correct
98 Correct 19 ms 600 KB Output is correct
99 Correct 34 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -