Submission #433264

# Submission time Handle Problem Language Result Execution time Memory
433264 2021-06-19T11:11:34 Z amunduzbaev Jelly Flavours (IOI20_jelly) C++14
24 / 100
233 ms 156832 KB
#include "jelly.h"

#ifndef EVAL
#include "grader.cpp"
#endif

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

const int N = 2005;
int dp[N][(int)1e4+5];
int rdp[N][(int)1e4+5];

#define ff first
#define ss second
template<class T> bool umin(T& a, const T b) { if(a > b) { a = b; return 1; } return 0; }
template<class T> bool umax(T& a, const T b) { if(a < b) { a = b; return 1; } return 0; }

const int mod = 1e9+7;
	
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
	int n = (int)a.size();
	vector<pair<int, int>> tt;
	for(int i=0;i<n;i++) tt.push_back({a[i], b[i]});
	tt.push_back({-1, -1});
	sort(tt.begin(), tt.end());
	
	memset(dp, 127, sizeof dp);
	memset(dp[0], 0, sizeof dp[0]);
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<=x;j++){
			if(~dp[i-1][j]) umin(dp[i][j], dp[i-1][j] + tt[i].ss);
			if(j >= tt[i].ff && ~dp[i-1][j-tt[i].ff]) umin(dp[i][j], dp[i-1][j - tt[i].ff]);
		}
	}
	
	for(int i=n;i>0;i--){
		for(int j=0;j<=y;j++){
			if(j) umax(rdp[i][j], rdp[i][j-1]);
			if(j >= tt[i].ss) umax(rdp[i][j], rdp[i+1][j-tt[i].ss] + 1);
		}
	}
	
	int res = 0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=x;j++){
			if(dp[i][j] <= y) umax(res, i + rdp[i+1][y - dp[i][j]]);
		}
	}
	
	//~ for(int j=0;j<=x;j++){
		//~ for(int i=1;i<=n;i++) cout<<dp[i][j]<<" ";
		//~ cout<<"\n";
	//~ } cout<<"\n";
	
	//~ for(int j=0;j<=y;j++){
		//~ for(int i=1;i<=n;i++) cout<<rdp[i][j]<<" ";
		//~ cout<<"\n";
	//~ } cout<<"\n";
	
	return res;
}

/*

	5 6 12
	5 1 5 6 3 
	3 5 4 6 7

*/
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 78788 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 78788 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 81552 KB 1st lines differ - on the 1st token, expected: '689', found: '65'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 139 ms 91920 KB Output is correct
2 Correct 174 ms 120900 KB Output is correct
3 Correct 154 ms 119364 KB Output is correct
4 Correct 225 ms 153420 KB Output is correct
5 Correct 217 ms 156172 KB Output is correct
6 Correct 168 ms 138052 KB Output is correct
7 Correct 171 ms 126920 KB Output is correct
8 Correct 136 ms 100912 KB Output is correct
9 Correct 202 ms 153612 KB Output is correct
10 Correct 229 ms 154692 KB Output is correct
11 Correct 108 ms 116884 KB Output is correct
12 Correct 35 ms 78736 KB Output is correct
13 Correct 109 ms 132360 KB Output is correct
14 Correct 133 ms 154760 KB Output is correct
15 Correct 133 ms 155176 KB Output is correct
16 Correct 111 ms 121816 KB Output is correct
17 Correct 97 ms 87364 KB Output is correct
18 Correct 115 ms 92444 KB Output is correct
19 Correct 118 ms 93000 KB Output is correct
20 Correct 105 ms 87932 KB Output is correct
21 Correct 112 ms 92052 KB Output is correct
22 Correct 153 ms 120876 KB Output is correct
23 Correct 148 ms 119356 KB Output is correct
24 Correct 233 ms 153400 KB Output is correct
25 Correct 206 ms 156172 KB Output is correct
26 Correct 172 ms 138052 KB Output is correct
27 Correct 166 ms 126868 KB Output is correct
28 Correct 133 ms 100804 KB Output is correct
29 Correct 202 ms 153652 KB Output is correct
30 Correct 210 ms 154692 KB Output is correct
31 Correct 107 ms 116828 KB Output is correct
32 Correct 37 ms 78832 KB Output is correct
33 Correct 117 ms 132368 KB Output is correct
34 Correct 135 ms 154880 KB Output is correct
35 Correct 156 ms 155072 KB Output is correct
36 Correct 100 ms 121860 KB Output is correct
37 Correct 102 ms 87260 KB Output is correct
38 Correct 106 ms 92436 KB Output is correct
39 Correct 119 ms 92976 KB Output is correct
40 Correct 104 ms 87892 KB Output is correct
41 Correct 110 ms 91988 KB Output is correct
42 Correct 149 ms 120900 KB Output is correct
43 Correct 153 ms 119396 KB Output is correct
44 Correct 213 ms 153432 KB Output is correct
45 Correct 208 ms 156168 KB Output is correct
46 Correct 213 ms 138000 KB Output is correct
47 Correct 162 ms 126980 KB Output is correct
48 Correct 138 ms 100848 KB Output is correct
49 Correct 224 ms 153660 KB Output is correct
50 Correct 211 ms 154820 KB Output is correct
51 Correct 108 ms 116904 KB Output is correct
52 Correct 39 ms 78768 KB Output is correct
53 Correct 120 ms 132528 KB Output is correct
54 Correct 140 ms 154708 KB Output is correct
55 Correct 159 ms 155072 KB Output is correct
56 Correct 106 ms 121796 KB Output is correct
57 Correct 102 ms 87240 KB Output is correct
58 Correct 115 ms 92440 KB Output is correct
59 Correct 128 ms 93016 KB Output is correct
60 Correct 108 ms 87872 KB Output is correct
61 Correct 107 ms 91960 KB Output is correct
62 Correct 157 ms 120868 KB Output is correct
63 Correct 174 ms 119644 KB Output is correct
64 Correct 210 ms 153484 KB Output is correct
65 Correct 212 ms 156188 KB Output is correct
66 Correct 177 ms 138052 KB Output is correct
67 Correct 168 ms 127044 KB Output is correct
68 Correct 145 ms 100808 KB Output is correct
69 Correct 203 ms 153612 KB Output is correct
70 Correct 211 ms 154844 KB Output is correct
71 Correct 110 ms 116908 KB Output is correct
72 Correct 41 ms 78856 KB Output is correct
73 Correct 120 ms 132404 KB Output is correct
74 Correct 139 ms 154764 KB Output is correct
75 Correct 143 ms 155180 KB Output is correct
76 Correct 110 ms 121856 KB Output is correct
77 Correct 106 ms 87312 KB Output is correct
78 Correct 108 ms 92544 KB Output is correct
79 Correct 123 ms 92996 KB Output is correct
80 Correct 110 ms 87876 KB Output is correct
81 Correct 106 ms 92068 KB Output is correct
82 Correct 160 ms 120904 KB Output is correct
83 Correct 159 ms 119396 KB Output is correct
84 Correct 218 ms 153624 KB Output is correct
85 Correct 209 ms 156232 KB Output is correct
86 Correct 174 ms 138052 KB Output is correct
87 Correct 186 ms 126916 KB Output is correct
88 Correct 140 ms 100808 KB Output is correct
89 Correct 199 ms 153672 KB Output is correct
90 Correct 208 ms 154820 KB Output is correct
91 Correct 109 ms 116908 KB Output is correct
92 Correct 41 ms 78792 KB Output is correct
93 Correct 124 ms 132420 KB Output is correct
94 Correct 158 ms 154816 KB Output is correct
95 Correct 144 ms 155148 KB Output is correct
96 Correct 111 ms 121828 KB Output is correct
97 Correct 99 ms 87308 KB Output is correct
98 Correct 106 ms 92484 KB Output is correct
99 Correct 123 ms 92952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 89104 KB Output is correct
2 Correct 159 ms 120232 KB Output is correct
3 Correct 167 ms 120848 KB Output is correct
4 Correct 224 ms 155464 KB Output is correct
5 Correct 207 ms 153412 KB Output is correct
6 Correct 164 ms 124188 KB Output is correct
7 Correct 164 ms 124376 KB Output is correct
8 Correct 188 ms 122012 KB Output is correct
9 Correct 207 ms 155808 KB Output is correct
10 Correct 227 ms 156812 KB Output is correct
11 Correct 142 ms 153564 KB Output is correct
12 Correct 46 ms 78756 KB Output is correct
13 Correct 148 ms 149376 KB Output is correct
14 Correct 144 ms 155880 KB Output is correct
15 Correct 153 ms 154084 KB Output is correct
16 Correct 138 ms 146796 KB Output is correct
17 Correct 110 ms 91308 KB Output is correct
18 Correct 112 ms 91336 KB Output is correct
19 Correct 114 ms 87480 KB Output is correct
20 Correct 126 ms 87236 KB Output is correct
21 Correct 108 ms 89280 KB Output is correct
22 Correct 159 ms 120224 KB Output is correct
23 Correct 158 ms 120876 KB Output is correct
24 Correct 216 ms 155456 KB Output is correct
25 Correct 206 ms 153228 KB Output is correct
26 Correct 163 ms 124176 KB Output is correct
27 Correct 178 ms 124332 KB Output is correct
28 Correct 169 ms 122148 KB Output is correct
29 Correct 203 ms 155708 KB Output is correct
30 Correct 212 ms 156812 KB Output is correct
31 Correct 147 ms 153608 KB Output is correct
32 Correct 40 ms 78804 KB Output is correct
33 Correct 161 ms 149368 KB Output is correct
34 Correct 145 ms 155844 KB Output is correct
35 Correct 151 ms 154044 KB Output is correct
36 Correct 159 ms 146860 KB Output is correct
37 Correct 136 ms 91332 KB Output is correct
38 Correct 109 ms 91304 KB Output is correct
39 Correct 116 ms 87364 KB Output is correct
40 Correct 123 ms 87236 KB Output is correct
41 Correct 111 ms 89232 KB Output is correct
42 Correct 173 ms 120168 KB Output is correct
43 Correct 157 ms 120808 KB Output is correct
44 Correct 213 ms 155452 KB Output is correct
45 Correct 209 ms 153280 KB Output is correct
46 Correct 164 ms 124228 KB Output is correct
47 Correct 165 ms 124340 KB Output is correct
48 Correct 161 ms 122032 KB Output is correct
49 Correct 214 ms 155740 KB Output is correct
50 Correct 213 ms 156832 KB Output is correct
51 Correct 141 ms 153512 KB Output is correct
52 Correct 43 ms 78736 KB Output is correct
53 Correct 158 ms 149324 KB Output is correct
54 Correct 160 ms 155912 KB Output is correct
55 Correct 151 ms 154080 KB Output is correct
56 Correct 137 ms 146764 KB Output is correct
57 Correct 112 ms 91420 KB Output is correct
58 Correct 111 ms 91332 KB Output is correct
59 Correct 119 ms 87460 KB Output is correct
60 Correct 118 ms 87360 KB Output is correct
61 Correct 107 ms 89108 KB Output is correct
62 Correct 160 ms 120132 KB Output is correct
63 Correct 155 ms 120772 KB Output is correct
64 Correct 213 ms 155404 KB Output is correct
65 Correct 225 ms 153308 KB Output is correct
66 Correct 160 ms 124268 KB Output is correct
67 Correct 165 ms 124364 KB Output is correct
68 Correct 160 ms 122012 KB Output is correct
69 Correct 200 ms 155788 KB Output is correct
70 Correct 209 ms 156812 KB Output is correct
71 Correct 142 ms 153540 KB Output is correct
72 Correct 41 ms 78796 KB Output is correct
73 Correct 146 ms 149332 KB Output is correct
74 Correct 164 ms 155844 KB Output is correct
75 Correct 150 ms 154152 KB Output is correct
76 Correct 134 ms 146900 KB Output is correct
77 Correct 121 ms 91396 KB Output is correct
78 Correct 109 ms 91364 KB Output is correct
79 Correct 116 ms 87364 KB Output is correct
80 Correct 121 ms 87284 KB Output is correct
81 Correct 107 ms 89240 KB Output is correct
82 Correct 166 ms 120144 KB Output is correct
83 Correct 156 ms 120856 KB Output is correct
84 Correct 207 ms 155368 KB Output is correct
85 Correct 206 ms 153284 KB Output is correct
86 Correct 160 ms 124228 KB Output is correct
87 Correct 164 ms 124416 KB Output is correct
88 Correct 178 ms 122004 KB Output is correct
89 Correct 200 ms 155716 KB Output is correct
90 Correct 212 ms 156808 KB Output is correct
91 Correct 143 ms 153540 KB Output is correct
92 Correct 40 ms 78768 KB Output is correct
93 Correct 141 ms 149300 KB Output is correct
94 Correct 148 ms 155844 KB Output is correct
95 Correct 152 ms 154136 KB Output is correct
96 Correct 135 ms 146756 KB Output is correct
97 Correct 115 ms 91328 KB Output is correct
98 Correct 111 ms 91344 KB Output is correct
99 Correct 116 ms 87592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 78788 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -