답안 #426591

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426591 2021-06-14T07:23:21 Z Apiram Jelly Flavours (IOI20_jelly) C++14
33 / 100
170 ms 152224 KB
#include "jelly.h"
#include <cstdio>
#include <cassert>
#include <vector>
#include<bits/stdc++.h>
using namespace std;
int find_maximum_unique(int x, int y, std::vector<int> arr, std::vector<int> brr) {
	int n = arr.size();
	bool ok=true;
	bool okay=true;
	for (int i =0;i<n;++i){
		if (arr[i]!=brr[i]){
			ok=false;
		}
		if (i>0){
			if (brr[i]!=brr[i-1])okay=false;
		}
	}
	if (okay){
		vector<pair<int,int>>crr(n);
		for (int i=0;i<n;++i){
			crr[i]={arr[i],brr[i]};
		}
		sort(crr.begin(),crr.end());
		int ans=0;
		n--;
		while(n>=0){
			if (y-crr[n].second>=0){
				y-=crr[n].second;
				--n;
				ans++;
			}
			else break;
		}
		for (int i =0;i<=n;++i){
			if (x-crr[i].first<0)break;
			x-=crr[i].first;
			ans++;
		}
		return ans;
	}
	if (!ok){
	vector<pair<int,int>>crr;
	for(int i =0;i<n;++i){
		crr.push_back({arr[i],brr[i]});
	}
	sort(crr.begin(),crr.end());
	vector<pair<int,int>>dp(x+1,{-1,-1});
	dp[0]={0,0};
	for (int i =0;i<n;++i){
		for (int j =x;j>=0;--j){
			if (dp[j].first==-1)continue;
			if (j+crr[i].first<=x&&(dp[j+crr[i].first].first==-1||dp[j+crr[i].first].first<dp[j].first+1)){
				dp[j+crr[i].first].first = dp[j].first+1;
				dp[j+crr[i].first].second=dp[j].second;
			}
			if (dp[j].second+crr[i].second<=y){
				dp[j].second=dp[j].second+crr[i].second;
				dp[j].first=dp[j].first+1;
				
				
			}
		}
	}
	int ans=0;
	for (int i =0;i<=x;++i){
		if (dp[i].second<=y)
		ans=max(ans,dp[i].first);
	}
	return ans;
	
	}
	else {
		int dp1[n+1][x+y+1];
		memset(dp1,0,sizeof dp1);
		for (int i =1;i<=n;++i){
			for (int j =0;j<=x+y;++j){
			dp1[i][j] = max({(j-arr[i-1]>=0)?dp1[i-1][j-arr[i-1]]+1:0,dp1[i][j],dp1[i-1][j]});
		}
	}
	return dp1[n][x+y];
}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '5', found: '4'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '5', found: '4'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 332 KB Output is correct
2 Correct 14 ms 384 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 6 ms 296 KB Output is correct
5 Correct 38 ms 412 KB Output is correct
6 Correct 55 ms 408 KB Output is correct
7 Correct 49 ms 412 KB Output is correct
8 Correct 11 ms 332 KB Output is correct
9 Correct 49 ms 332 KB Output is correct
10 Correct 17 ms 388 KB Output is correct
11 Correct 39 ms 420 KB Output is correct
12 Correct 33 ms 332 KB Output is correct
13 Correct 28 ms 332 KB Output is correct
14 Correct 9 ms 332 KB Output is correct
15 Correct 30 ms 388 KB Output is correct
16 Correct 33 ms 332 KB Output is correct
17 Correct 33 ms 332 KB Output is correct
18 Correct 43 ms 332 KB Output is correct
19 Correct 27 ms 380 KB Output is correct
20 Correct 10 ms 356 KB Output is correct
21 Correct 10 ms 368 KB Output is correct
22 Correct 14 ms 384 KB Output is correct
23 Correct 5 ms 300 KB Output is correct
24 Correct 6 ms 332 KB Output is correct
25 Correct 31 ms 332 KB Output is correct
26 Correct 47 ms 420 KB Output is correct
27 Correct 46 ms 416 KB Output is correct
28 Correct 10 ms 356 KB Output is correct
29 Correct 41 ms 412 KB Output is correct
30 Correct 22 ms 292 KB Output is correct
31 Correct 42 ms 332 KB Output is correct
32 Correct 33 ms 324 KB Output is correct
33 Correct 33 ms 332 KB Output is correct
34 Correct 9 ms 348 KB Output is correct
35 Correct 37 ms 332 KB Output is correct
36 Correct 30 ms 392 KB Output is correct
37 Correct 40 ms 332 KB Output is correct
38 Correct 33 ms 332 KB Output is correct
39 Correct 25 ms 404 KB Output is correct
40 Correct 9 ms 332 KB Output is correct
41 Correct 10 ms 332 KB Output is correct
42 Correct 17 ms 388 KB Output is correct
43 Correct 6 ms 332 KB Output is correct
44 Correct 8 ms 332 KB Output is correct
45 Correct 35 ms 420 KB Output is correct
46 Correct 48 ms 424 KB Output is correct
47 Correct 45 ms 332 KB Output is correct
48 Correct 10 ms 332 KB Output is correct
49 Correct 42 ms 332 KB Output is correct
50 Correct 17 ms 384 KB Output is correct
51 Correct 38 ms 332 KB Output is correct
52 Correct 30 ms 332 KB Output is correct
53 Correct 31 ms 392 KB Output is correct
54 Correct 9 ms 356 KB Output is correct
55 Correct 30 ms 332 KB Output is correct
56 Correct 32 ms 332 KB Output is correct
57 Correct 33 ms 332 KB Output is correct
58 Correct 35 ms 332 KB Output is correct
59 Correct 23 ms 396 KB Output is correct
60 Correct 9 ms 332 KB Output is correct
61 Correct 10 ms 332 KB Output is correct
62 Correct 20 ms 332 KB Output is correct
63 Correct 5 ms 368 KB Output is correct
64 Correct 9 ms 300 KB Output is correct
65 Correct 34 ms 300 KB Output is correct
66 Correct 49 ms 332 KB Output is correct
67 Correct 46 ms 332 KB Output is correct
68 Correct 10 ms 360 KB Output is correct
69 Correct 45 ms 332 KB Output is correct
70 Correct 17 ms 332 KB Output is correct
71 Correct 44 ms 412 KB Output is correct
72 Correct 33 ms 332 KB Output is correct
73 Correct 37 ms 388 KB Output is correct
74 Correct 9 ms 296 KB Output is correct
75 Correct 31 ms 408 KB Output is correct
76 Correct 32 ms 416 KB Output is correct
77 Correct 38 ms 332 KB Output is correct
78 Correct 45 ms 400 KB Output is correct
79 Correct 30 ms 400 KB Output is correct
80 Correct 9 ms 360 KB Output is correct
81 Correct 10 ms 332 KB Output is correct
82 Correct 14 ms 332 KB Output is correct
83 Correct 5 ms 332 KB Output is correct
84 Correct 6 ms 360 KB Output is correct
85 Correct 34 ms 332 KB Output is correct
86 Correct 56 ms 412 KB Output is correct
87 Correct 44 ms 332 KB Output is correct
88 Correct 10 ms 356 KB Output is correct
89 Correct 42 ms 332 KB Output is correct
90 Correct 17 ms 392 KB Output is correct
91 Correct 42 ms 304 KB Output is correct
92 Correct 31 ms 332 KB Output is correct
93 Correct 30 ms 332 KB Output is correct
94 Correct 9 ms 332 KB Output is correct
95 Correct 30 ms 404 KB Output is correct
96 Correct 33 ms 308 KB Output is correct
97 Correct 34 ms 396 KB Output is correct
98 Correct 36 ms 396 KB Output is correct
99 Correct 23 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 2 ms 204 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 232 KB Output is correct
41 Correct 2 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 2 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 2 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 2 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 204 KB Output is correct
56 Correct 1 ms 204 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 332 KB Output is correct
60 Correct 2 ms 304 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 384 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 1 ms 332 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 2 ms 332 KB Output is correct
67 Correct 1 ms 332 KB Output is correct
68 Correct 1 ms 332 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
71 Correct 1 ms 332 KB Output is correct
72 Correct 1 ms 332 KB Output is correct
73 Correct 1 ms 332 KB Output is correct
74 Correct 2 ms 204 KB Output is correct
75 Correct 1 ms 384 KB Output is correct
76 Correct 1 ms 332 KB Output is correct
77 Correct 1 ms 332 KB Output is correct
78 Correct 2 ms 332 KB Output is correct
79 Correct 2 ms 204 KB Output is correct
80 Correct 1 ms 332 KB Output is correct
81 Correct 1 ms 204 KB Output is correct
82 Correct 1 ms 332 KB Output is correct
83 Correct 1 ms 300 KB Output is correct
84 Correct 1 ms 332 KB Output is correct
85 Correct 1 ms 332 KB Output is correct
86 Correct 2 ms 204 KB Output is correct
87 Correct 1 ms 332 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 1 ms 332 KB Output is correct
90 Correct 1 ms 332 KB Output is correct
91 Correct 1 ms 332 KB Output is correct
92 Correct 1 ms 332 KB Output is correct
93 Correct 1 ms 332 KB Output is correct
94 Correct 1 ms 332 KB Output is correct
95 Correct 1 ms 332 KB Output is correct
96 Correct 1 ms 332 KB Output is correct
97 Correct 1 ms 332 KB Output is correct
98 Correct 2 ms 332 KB Output is correct
99 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 79336 KB Output is correct
2 Correct 137 ms 141272 KB Output is correct
3 Correct 141 ms 140340 KB Output is correct
4 Correct 146 ms 147936 KB Output is correct
5 Correct 143 ms 143564 KB Output is correct
6 Correct 147 ms 145560 KB Output is correct
7 Correct 143 ms 146836 KB Output is correct
8 Correct 138 ms 143560 KB Output is correct
9 Correct 140 ms 142232 KB Output is correct
10 Correct 146 ms 152224 KB Output is correct
11 Correct 72 ms 74204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 85 ms 87964 KB Output is correct
14 Correct 81 ms 78020 KB Output is correct
15 Correct 99 ms 84604 KB Output is correct
16 Correct 81 ms 78012 KB Output is correct
17 Correct 84 ms 85544 KB Output is correct
18 Correct 82 ms 85140 KB Output is correct
19 Correct 82 ms 76108 KB Output is correct
20 Correct 79 ms 77168 KB Output is correct
21 Correct 81 ms 79308 KB Output is correct
22 Correct 168 ms 141252 KB Output is correct
23 Correct 138 ms 140336 KB Output is correct
24 Correct 143 ms 147856 KB Output is correct
25 Correct 140 ms 143556 KB Output is correct
26 Correct 138 ms 145604 KB Output is correct
27 Correct 138 ms 146880 KB Output is correct
28 Correct 139 ms 143360 KB Output is correct
29 Correct 136 ms 142208 KB Output is correct
30 Correct 147 ms 152116 KB Output is correct
31 Correct 73 ms 74308 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 85 ms 87960 KB Output is correct
34 Correct 78 ms 78092 KB Output is correct
35 Correct 88 ms 84540 KB Output is correct
36 Correct 79 ms 78064 KB Output is correct
37 Correct 84 ms 85580 KB Output is correct
38 Correct 85 ms 85068 KB Output is correct
39 Correct 75 ms 76100 KB Output is correct
40 Correct 79 ms 77124 KB Output is correct
41 Correct 96 ms 79268 KB Output is correct
42 Correct 133 ms 141284 KB Output is correct
43 Correct 150 ms 140404 KB Output is correct
44 Correct 167 ms 147908 KB Output is correct
45 Correct 142 ms 143680 KB Output is correct
46 Correct 136 ms 145600 KB Output is correct
47 Correct 141 ms 146828 KB Output is correct
48 Correct 138 ms 143436 KB Output is correct
49 Correct 135 ms 142128 KB Output is correct
50 Correct 166 ms 152044 KB Output is correct
51 Correct 74 ms 74316 KB Output is correct
52 Correct 2 ms 332 KB Output is correct
53 Correct 86 ms 87876 KB Output is correct
54 Correct 80 ms 78020 KB Output is correct
55 Correct 84 ms 84636 KB Output is correct
56 Correct 78 ms 77952 KB Output is correct
57 Correct 87 ms 85580 KB Output is correct
58 Correct 83 ms 85156 KB Output is correct
59 Correct 75 ms 76008 KB Output is correct
60 Correct 77 ms 77124 KB Output is correct
61 Correct 94 ms 79300 KB Output is correct
62 Correct 136 ms 141276 KB Output is correct
63 Correct 140 ms 140340 KB Output is correct
64 Correct 151 ms 147852 KB Output is correct
65 Correct 166 ms 143656 KB Output is correct
66 Correct 138 ms 145604 KB Output is correct
67 Correct 143 ms 146956 KB Output is correct
68 Correct 135 ms 143396 KB Output is correct
69 Correct 170 ms 142228 KB Output is correct
70 Correct 160 ms 152056 KB Output is correct
71 Correct 73 ms 74308 KB Output is correct
72 Correct 1 ms 332 KB Output is correct
73 Correct 88 ms 87912 KB Output is correct
74 Correct 81 ms 78036 KB Output is correct
75 Correct 82 ms 84428 KB Output is correct
76 Correct 95 ms 78084 KB Output is correct
77 Correct 106 ms 85472 KB Output is correct
78 Correct 83 ms 85060 KB Output is correct
79 Correct 75 ms 76028 KB Output is correct
80 Correct 76 ms 77084 KB Output is correct
81 Correct 80 ms 79332 KB Output is correct
82 Correct 158 ms 141284 KB Output is correct
83 Correct 138 ms 140436 KB Output is correct
84 Correct 144 ms 147824 KB Output is correct
85 Correct 145 ms 143672 KB Output is correct
86 Correct 165 ms 145604 KB Output is correct
87 Correct 144 ms 147024 KB Output is correct
88 Correct 159 ms 143428 KB Output is correct
89 Correct 167 ms 142204 KB Output is correct
90 Correct 154 ms 152096 KB Output is correct
91 Correct 74 ms 74312 KB Output is correct
92 Correct 1 ms 332 KB Output is correct
93 Correct 87 ms 87964 KB Output is correct
94 Correct 76 ms 78028 KB Output is correct
95 Correct 88 ms 84472 KB Output is correct
96 Correct 79 ms 78072 KB Output is correct
97 Correct 84 ms 85552 KB Output is correct
98 Correct 82 ms 85080 KB Output is correct
99 Correct 77 ms 76116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '5', found: '4'
9 Halted 0 ms 0 KB -