Submission #316949

# Submission time Handle Problem Language Result Execution time Memory
316949 2020-10-28T16:46:54 Z mihai145 Jelly Flavours (IOI20_jelly) C++14
24 / 100
245 ms 78760 KB
#include "jelly.h"
#include <vector>
#include <algorithm>

const int NMAX = 2000;
const int XMAX = 10000;
const int INF = 10 * XMAX;

std::vector < std::pair <int, int> > pairs;
int dp[NMAX + 2][XMAX + 2];

int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
	int n = (int)a.size();

	for(int i = 0; i < n; i++)
        pairs.push_back({a[i], b[i]});

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

	for(int i = 1; i <= n; i++)
        for(int bugA = 0; bugA <= x; bugA++)
            dp[i][bugA] = INF;

    for(int i = 0; i < n; i++)
        for(int bugA = 0; bugA <= x; bugA++)
            {
                ///cumpar i + 1 din A
                if(bugA + pairs[i].first <= x)
                    dp[i + 1][bugA + pairs[i].first] = std::min(dp[i + 1][bugA + pairs[i].first], dp[i][bugA]);

                ///cumpar i + 1 din B
                dp[i + 1][bugA] = std::min(dp[i + 1][bugA], dp[i][bugA] + pairs[i].second);
            }

    std::vector <int> sufb;
    int sol = 0;

    for(int i = n; i >= 0; i--)
        {
            int minY = INF;
            for(int bugA = 0; bugA <= x; bugA++)
                minY = std::min(minY, dp[i][bugA]);

            if(minY <= y) {
                int placed = i; ///pref

                if(i + 1 <= n)
                    sufb.push_back(pairs[i].second);

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

                int remBudget = y - minY;
                for(auto it : sufb)
                if(remBudget >= it) {
                    remBudget -= it;
                    placed++;
                } else
                    break;

                sol = std::max(sol, placed);
            }
        }

	return sol;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 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 1 ms 384 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 28 ms 21248 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 128 ms 76156 KB Output is correct
2 Correct 128 ms 78072 KB Output is correct
3 Correct 133 ms 78328 KB Output is correct
4 Correct 177 ms 75128 KB Output is correct
5 Correct 178 ms 77688 KB Output is correct
6 Correct 127 ms 74940 KB Output is correct
7 Correct 130 ms 77304 KB Output is correct
8 Correct 139 ms 75256 KB Output is correct
9 Correct 178 ms 75256 KB Output is correct
10 Correct 174 ms 76280 KB Output is correct
11 Correct 13 ms 12416 KB Output is correct
12 Correct 5 ms 8064 KB Output is correct
13 Correct 8 ms 9600 KB Output is correct
14 Correct 23 ms 9728 KB Output is correct
15 Correct 20 ms 12160 KB Output is correct
16 Correct 6 ms 8832 KB Output is correct
17 Correct 131 ms 78584 KB Output is correct
18 Correct 129 ms 74744 KB Output is correct
19 Correct 170 ms 76684 KB Output is correct
20 Correct 164 ms 77176 KB Output is correct
21 Correct 127 ms 76152 KB Output is correct
22 Correct 129 ms 77944 KB Output is correct
23 Correct 135 ms 78328 KB Output is correct
24 Correct 183 ms 75000 KB Output is correct
25 Correct 181 ms 77820 KB Output is correct
26 Correct 128 ms 74872 KB Output is correct
27 Correct 125 ms 77304 KB Output is correct
28 Correct 130 ms 75296 KB Output is correct
29 Correct 178 ms 75384 KB Output is correct
30 Correct 174 ms 76408 KB Output is correct
31 Correct 13 ms 12416 KB Output is correct
32 Correct 5 ms 8064 KB Output is correct
33 Correct 8 ms 9600 KB Output is correct
34 Correct 23 ms 9728 KB Output is correct
35 Correct 19 ms 12160 KB Output is correct
36 Correct 6 ms 8832 KB Output is correct
37 Correct 131 ms 78584 KB Output is correct
38 Correct 127 ms 74744 KB Output is correct
39 Correct 176 ms 76792 KB Output is correct
40 Correct 164 ms 77176 KB Output is correct
41 Correct 130 ms 76152 KB Output is correct
42 Correct 129 ms 77944 KB Output is correct
43 Correct 135 ms 78328 KB Output is correct
44 Correct 178 ms 75020 KB Output is correct
45 Correct 182 ms 77692 KB Output is correct
46 Correct 128 ms 75000 KB Output is correct
47 Correct 129 ms 77304 KB Output is correct
48 Correct 130 ms 75384 KB Output is correct
49 Correct 176 ms 75252 KB Output is correct
50 Correct 168 ms 76280 KB Output is correct
51 Correct 13 ms 12416 KB Output is correct
52 Correct 5 ms 8064 KB Output is correct
53 Correct 9 ms 9600 KB Output is correct
54 Correct 23 ms 9728 KB Output is correct
55 Correct 19 ms 12256 KB Output is correct
56 Correct 6 ms 8832 KB Output is correct
57 Correct 129 ms 78584 KB Output is correct
58 Correct 135 ms 74872 KB Output is correct
59 Correct 177 ms 76664 KB Output is correct
60 Correct 167 ms 77048 KB Output is correct
61 Correct 128 ms 76152 KB Output is correct
62 Correct 128 ms 78028 KB Output is correct
63 Correct 131 ms 78328 KB Output is correct
64 Correct 171 ms 75000 KB Output is correct
65 Correct 182 ms 77816 KB Output is correct
66 Correct 126 ms 74876 KB Output is correct
67 Correct 129 ms 77304 KB Output is correct
68 Correct 131 ms 75256 KB Output is correct
69 Correct 180 ms 75384 KB Output is correct
70 Correct 174 ms 76280 KB Output is correct
71 Correct 13 ms 12416 KB Output is correct
72 Correct 5 ms 8064 KB Output is correct
73 Correct 8 ms 9600 KB Output is correct
74 Correct 23 ms 9728 KB Output is correct
75 Correct 19 ms 12160 KB Output is correct
76 Correct 7 ms 8832 KB Output is correct
77 Correct 131 ms 78660 KB Output is correct
78 Correct 128 ms 74744 KB Output is correct
79 Correct 181 ms 76664 KB Output is correct
80 Correct 166 ms 77176 KB Output is correct
81 Correct 130 ms 76280 KB Output is correct
82 Correct 132 ms 78072 KB Output is correct
83 Correct 137 ms 78456 KB Output is correct
84 Correct 175 ms 75020 KB Output is correct
85 Correct 180 ms 77688 KB Output is correct
86 Correct 126 ms 74872 KB Output is correct
87 Correct 129 ms 77304 KB Output is correct
88 Correct 133 ms 75256 KB Output is correct
89 Correct 178 ms 75256 KB Output is correct
90 Correct 178 ms 76280 KB Output is correct
91 Correct 13 ms 12416 KB Output is correct
92 Correct 5 ms 8064 KB Output is correct
93 Correct 8 ms 9600 KB Output is correct
94 Correct 23 ms 9744 KB Output is correct
95 Correct 19 ms 12160 KB Output is correct
96 Correct 6 ms 8832 KB Output is correct
97 Correct 131 ms 78760 KB Output is correct
98 Correct 124 ms 74948 KB Output is correct
99 Correct 176 ms 76664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 77096 KB Output is correct
2 Correct 146 ms 75128 KB Output is correct
3 Correct 136 ms 77304 KB Output is correct
4 Correct 239 ms 76920 KB Output is correct
5 Correct 221 ms 74744 KB Output is correct
6 Correct 130 ms 77136 KB Output is correct
7 Correct 130 ms 78128 KB Output is correct
8 Correct 128 ms 75256 KB Output is correct
9 Correct 230 ms 77328 KB Output is correct
10 Correct 239 ms 78328 KB Output is correct
11 Correct 11 ms 11392 KB Output is correct
12 Correct 5 ms 8320 KB Output is correct
13 Correct 29 ms 22144 KB Output is correct
14 Correct 67 ms 11776 KB Output is correct
15 Correct 91 ms 22784 KB Output is correct
16 Correct 22 ms 18304 KB Output is correct
17 Correct 151 ms 78456 KB Output is correct
18 Correct 150 ms 78072 KB Output is correct
19 Correct 212 ms 77560 KB Output is correct
20 Correct 225 ms 78328 KB Output is correct
21 Correct 155 ms 77048 KB Output is correct
22 Correct 131 ms 75128 KB Output is correct
23 Correct 127 ms 77304 KB Output is correct
24 Correct 238 ms 76920 KB Output is correct
25 Correct 233 ms 74744 KB Output is correct
26 Correct 125 ms 77052 KB Output is correct
27 Correct 129 ms 77944 KB Output is correct
28 Correct 125 ms 75128 KB Output is correct
29 Correct 230 ms 77304 KB Output is correct
30 Correct 234 ms 78456 KB Output is correct
31 Correct 12 ms 11392 KB Output is correct
32 Correct 5 ms 8320 KB Output is correct
33 Correct 28 ms 22144 KB Output is correct
34 Correct 70 ms 11896 KB Output is correct
35 Correct 91 ms 22784 KB Output is correct
36 Correct 25 ms 18304 KB Output is correct
37 Correct 151 ms 78456 KB Output is correct
38 Correct 145 ms 78200 KB Output is correct
39 Correct 214 ms 77560 KB Output is correct
40 Correct 222 ms 78328 KB Output is correct
41 Correct 153 ms 77048 KB Output is correct
42 Correct 131 ms 75256 KB Output is correct
43 Correct 128 ms 77432 KB Output is correct
44 Correct 243 ms 76920 KB Output is correct
45 Correct 227 ms 74820 KB Output is correct
46 Correct 128 ms 77048 KB Output is correct
47 Correct 132 ms 77948 KB Output is correct
48 Correct 127 ms 75136 KB Output is correct
49 Correct 226 ms 77304 KB Output is correct
50 Correct 240 ms 78456 KB Output is correct
51 Correct 11 ms 11392 KB Output is correct
52 Correct 5 ms 8320 KB Output is correct
53 Correct 29 ms 22144 KB Output is correct
54 Correct 67 ms 11776 KB Output is correct
55 Correct 95 ms 22904 KB Output is correct
56 Correct 22 ms 18304 KB Output is correct
57 Correct 150 ms 78328 KB Output is correct
58 Correct 150 ms 78200 KB Output is correct
59 Correct 211 ms 77644 KB Output is correct
60 Correct 220 ms 78200 KB Output is correct
61 Correct 155 ms 77048 KB Output is correct
62 Correct 131 ms 75256 KB Output is correct
63 Correct 127 ms 77304 KB Output is correct
64 Correct 245 ms 77048 KB Output is correct
65 Correct 225 ms 74744 KB Output is correct
66 Correct 128 ms 77048 KB Output is correct
67 Correct 132 ms 78072 KB Output is correct
68 Correct 128 ms 75256 KB Output is correct
69 Correct 228 ms 77432 KB Output is correct
70 Correct 237 ms 78392 KB Output is correct
71 Correct 11 ms 11392 KB Output is correct
72 Correct 5 ms 8320 KB Output is correct
73 Correct 28 ms 22144 KB Output is correct
74 Correct 68 ms 11776 KB Output is correct
75 Correct 96 ms 22904 KB Output is correct
76 Correct 22 ms 18304 KB Output is correct
77 Correct 151 ms 78328 KB Output is correct
78 Correct 154 ms 78188 KB Output is correct
79 Correct 216 ms 77644 KB Output is correct
80 Correct 222 ms 78200 KB Output is correct
81 Correct 149 ms 77048 KB Output is correct
82 Correct 133 ms 75256 KB Output is correct
83 Correct 123 ms 77432 KB Output is correct
84 Correct 232 ms 76920 KB Output is correct
85 Correct 223 ms 74744 KB Output is correct
86 Correct 127 ms 77048 KB Output is correct
87 Correct 128 ms 77944 KB Output is correct
88 Correct 127 ms 75128 KB Output is correct
89 Correct 232 ms 77304 KB Output is correct
90 Correct 240 ms 78328 KB Output is correct
91 Correct 11 ms 11392 KB Output is correct
92 Correct 5 ms 8320 KB Output is correct
93 Correct 28 ms 22144 KB Output is correct
94 Correct 68 ms 11776 KB Output is correct
95 Correct 97 ms 22904 KB Output is correct
96 Correct 23 ms 18304 KB Output is correct
97 Correct 153 ms 78324 KB Output is correct
98 Correct 150 ms 78072 KB Output is correct
99 Correct 216 ms 77560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -