Submission #316943

# Submission time Handle Problem Language Result Execution time Memory
316943 2020-10-28T16:21:15 Z mihai145 Jelly Flavours (IOI20_jelly) C++14
24 / 100
205 ms 78584 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 = 0; i <= n; i++)
        for(int bugA = 0; bugA <= x; bugA++)
            dp[i][bugA] = INF;

    dp[0][0] = 0;

    for(int i = 0; i < n; i++)
        for(int bugA = 0; bugA <= x; bugA++)
            if(dp[i][bugA] <= y)
            {
                ///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
                if(dp[i][bugA] + pairs[i].second <= y)
                    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 0 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 0 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 22 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 90 ms 76152 KB Output is correct
2 Correct 93 ms 78104 KB Output is correct
3 Correct 94 ms 78328 KB Output is correct
4 Correct 149 ms 75068 KB Output is correct
5 Correct 147 ms 77816 KB Output is correct
6 Correct 90 ms 74872 KB Output is correct
7 Correct 94 ms 77304 KB Output is correct
8 Correct 96 ms 75256 KB Output is correct
9 Correct 146 ms 75256 KB Output is correct
10 Correct 157 ms 76464 KB Output is correct
11 Correct 11 ms 12416 KB Output is correct
12 Correct 5 ms 8064 KB Output is correct
13 Correct 7 ms 9600 KB Output is correct
14 Correct 23 ms 9728 KB Output is correct
15 Correct 21 ms 12160 KB Output is correct
16 Correct 6 ms 8832 KB Output is correct
17 Correct 92 ms 78584 KB Output is correct
18 Correct 89 ms 74872 KB Output is correct
19 Correct 116 ms 76664 KB Output is correct
20 Correct 102 ms 77176 KB Output is correct
21 Correct 91 ms 76280 KB Output is correct
22 Correct 92 ms 77944 KB Output is correct
23 Correct 95 ms 78328 KB Output is correct
24 Correct 146 ms 75128 KB Output is correct
25 Correct 147 ms 77816 KB Output is correct
26 Correct 92 ms 74872 KB Output is correct
27 Correct 92 ms 77304 KB Output is correct
28 Correct 95 ms 75256 KB Output is correct
29 Correct 141 ms 75256 KB Output is correct
30 Correct 146 ms 76280 KB Output is correct
31 Correct 10 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 24 ms 9728 KB Output is correct
35 Correct 17 ms 12160 KB Output is correct
36 Correct 6 ms 8832 KB Output is correct
37 Correct 95 ms 78584 KB Output is correct
38 Correct 91 ms 74872 KB Output is correct
39 Correct 115 ms 76792 KB Output is correct
40 Correct 100 ms 77176 KB Output is correct
41 Correct 94 ms 76116 KB Output is correct
42 Correct 94 ms 78072 KB Output is correct
43 Correct 98 ms 78328 KB Output is correct
44 Correct 149 ms 75000 KB Output is correct
45 Correct 146 ms 77816 KB Output is correct
46 Correct 91 ms 74872 KB Output is correct
47 Correct 93 ms 77308 KB Output is correct
48 Correct 98 ms 75384 KB Output is correct
49 Correct 144 ms 75256 KB Output is correct
50 Correct 139 ms 76280 KB Output is correct
51 Correct 11 ms 12416 KB Output is correct
52 Correct 5 ms 8064 KB Output is correct
53 Correct 8 ms 9600 KB Output is correct
54 Correct 24 ms 9856 KB Output is correct
55 Correct 17 ms 12160 KB Output is correct
56 Correct 6 ms 8916 KB Output is correct
57 Correct 93 ms 78584 KB Output is correct
58 Correct 92 ms 74876 KB Output is correct
59 Correct 119 ms 76704 KB Output is correct
60 Correct 99 ms 77180 KB Output is correct
61 Correct 89 ms 76156 KB Output is correct
62 Correct 93 ms 77944 KB Output is correct
63 Correct 95 ms 78328 KB Output is correct
64 Correct 147 ms 75000 KB Output is correct
65 Correct 144 ms 77820 KB Output is correct
66 Correct 92 ms 74872 KB Output is correct
67 Correct 96 ms 77304 KB Output is correct
68 Correct 93 ms 75332 KB Output is correct
69 Correct 143 ms 75292 KB Output is correct
70 Correct 146 ms 76280 KB Output is correct
71 Correct 11 ms 12416 KB Output is correct
72 Correct 5 ms 8192 KB Output is correct
73 Correct 7 ms 9600 KB Output is correct
74 Correct 24 ms 9728 KB Output is correct
75 Correct 18 ms 12160 KB Output is correct
76 Correct 6 ms 8832 KB Output is correct
77 Correct 92 ms 78584 KB Output is correct
78 Correct 89 ms 74872 KB Output is correct
79 Correct 115 ms 76792 KB Output is correct
80 Correct 102 ms 77176 KB Output is correct
81 Correct 92 ms 76152 KB Output is correct
82 Correct 93 ms 77948 KB Output is correct
83 Correct 93 ms 78328 KB Output is correct
84 Correct 147 ms 75128 KB Output is correct
85 Correct 148 ms 77820 KB Output is correct
86 Correct 90 ms 75000 KB Output is correct
87 Correct 94 ms 77432 KB Output is correct
88 Correct 93 ms 75256 KB Output is correct
89 Correct 143 ms 75256 KB Output is correct
90 Correct 145 ms 76280 KB Output is correct
91 Correct 12 ms 12416 KB Output is correct
92 Correct 5 ms 8064 KB Output is correct
93 Correct 7 ms 9600 KB Output is correct
94 Correct 24 ms 9728 KB Output is correct
95 Correct 18 ms 12160 KB Output is correct
96 Correct 6 ms 8832 KB Output is correct
97 Correct 94 ms 78584 KB Output is correct
98 Correct 90 ms 74872 KB Output is correct
99 Correct 116 ms 76664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 77128 KB Output is correct
2 Correct 97 ms 75256 KB Output is correct
3 Correct 97 ms 77304 KB Output is correct
4 Correct 198 ms 76996 KB Output is correct
5 Correct 196 ms 74872 KB Output is correct
6 Correct 93 ms 77048 KB Output is correct
7 Correct 93 ms 78072 KB Output is correct
8 Correct 95 ms 75168 KB Output is correct
9 Correct 205 ms 77368 KB Output is correct
10 Correct 196 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 23 ms 22144 KB Output is correct
14 Correct 66 ms 11776 KB Output is correct
15 Correct 87 ms 22784 KB Output is correct
16 Correct 19 ms 18304 KB Output is correct
17 Correct 93 ms 78328 KB Output is correct
18 Correct 93 ms 78328 KB Output is correct
19 Correct 144 ms 77564 KB Output is correct
20 Correct 144 ms 78328 KB Output is correct
21 Correct 91 ms 77048 KB Output is correct
22 Correct 92 ms 75260 KB Output is correct
23 Correct 91 ms 77304 KB Output is correct
24 Correct 195 ms 76920 KB Output is correct
25 Correct 184 ms 74752 KB Output is correct
26 Correct 92 ms 77296 KB Output is correct
27 Correct 92 ms 78112 KB Output is correct
28 Correct 91 ms 75128 KB Output is correct
29 Correct 189 ms 77304 KB Output is correct
30 Correct 200 ms 78460 KB Output is correct
31 Correct 10 ms 11392 KB Output is correct
32 Correct 5 ms 8320 KB Output is correct
33 Correct 23 ms 22144 KB Output is correct
34 Correct 67 ms 11896 KB Output is correct
35 Correct 88 ms 22904 KB Output is correct
36 Correct 18 ms 18304 KB Output is correct
37 Correct 93 ms 78328 KB Output is correct
38 Correct 91 ms 78200 KB Output is correct
39 Correct 146 ms 77688 KB Output is correct
40 Correct 145 ms 78332 KB Output is correct
41 Correct 91 ms 77048 KB Output is correct
42 Correct 93 ms 75256 KB Output is correct
43 Correct 92 ms 77304 KB Output is correct
44 Correct 198 ms 76920 KB Output is correct
45 Correct 193 ms 74744 KB Output is correct
46 Correct 92 ms 77048 KB Output is correct
47 Correct 93 ms 78072 KB Output is correct
48 Correct 92 ms 75256 KB Output is correct
49 Correct 189 ms 77304 KB Output is correct
50 Correct 202 ms 78456 KB Output is correct
51 Correct 10 ms 11392 KB Output is correct
52 Correct 5 ms 8320 KB Output is correct
53 Correct 23 ms 22144 KB Output is correct
54 Correct 66 ms 11896 KB Output is correct
55 Correct 87 ms 22888 KB Output is correct
56 Correct 20 ms 18304 KB Output is correct
57 Correct 94 ms 78328 KB Output is correct
58 Correct 92 ms 78200 KB Output is correct
59 Correct 143 ms 77560 KB Output is correct
60 Correct 147 ms 78328 KB Output is correct
61 Correct 91 ms 77048 KB Output is correct
62 Correct 92 ms 75256 KB Output is correct
63 Correct 114 ms 77304 KB Output is correct
64 Correct 197 ms 77048 KB Output is correct
65 Correct 183 ms 74744 KB Output is correct
66 Correct 92 ms 77048 KB Output is correct
67 Correct 93 ms 78044 KB Output is correct
68 Correct 92 ms 75256 KB Output is correct
69 Correct 190 ms 77304 KB Output is correct
70 Correct 199 ms 78456 KB Output is correct
71 Correct 10 ms 11392 KB Output is correct
72 Correct 5 ms 8320 KB Output is correct
73 Correct 23 ms 22144 KB Output is correct
74 Correct 66 ms 11896 KB Output is correct
75 Correct 92 ms 22784 KB Output is correct
76 Correct 19 ms 18304 KB Output is correct
77 Correct 93 ms 78328 KB Output is correct
78 Correct 93 ms 78328 KB Output is correct
79 Correct 145 ms 77560 KB Output is correct
80 Correct 145 ms 78328 KB Output is correct
81 Correct 93 ms 77176 KB Output is correct
82 Correct 96 ms 75384 KB Output is correct
83 Correct 94 ms 77304 KB Output is correct
84 Correct 196 ms 76920 KB Output is correct
85 Correct 186 ms 74872 KB Output is correct
86 Correct 94 ms 77048 KB Output is correct
87 Correct 93 ms 78072 KB Output is correct
88 Correct 92 ms 75256 KB Output is correct
89 Correct 189 ms 77304 KB Output is correct
90 Correct 196 ms 78424 KB Output is correct
91 Correct 11 ms 11392 KB Output is correct
92 Correct 6 ms 8320 KB Output is correct
93 Correct 23 ms 22144 KB Output is correct
94 Correct 67 ms 11776 KB Output is correct
95 Correct 86 ms 22784 KB Output is correct
96 Correct 19 ms 18304 KB Output is correct
97 Correct 98 ms 78328 KB Output is correct
98 Correct 105 ms 78200 KB Output is correct
99 Correct 144 ms 77688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -