Submission #522115

# Submission time Handle Problem Language Result Execution time Memory
522115 2022-02-03T21:09:00 Z tabr Jelly Flavours (IOI20_jelly) C++17
24 / 100
29 ms 31816 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
    int n = (int) a.size();
    vector<int> order(n);
    iota(order.begin(), order.end(), 0);
    sort(order.begin(), order.end(), [&](int i, int j) { return a[i] - b[i] < a[j] - b[j]; });
    const int inf = (int) 1e9;
    vector<vector<int>> dp1(n + 1, vector<int>(n + 1, inf));
    dp1[0][0] = 0;
    for (int i = 0; i < n; i++) {
        dp1[i + 1] = dp1[i];
        for (int j = i; j >= 0; j--) {
            dp1[i + 1][j + 1] = min(dp1[i + 1][j + 1], dp1[i][j] + a[order[i]]);
        }
    }
    vector<vector<int>> dp2(n + 1, vector<int>(n + 1, inf));
    dp2[0][0] = 0;
    for (int i = 0; i < n; i++) {
        dp2[i + 1] = dp2[i];
        for (int j = i; j >= 0; j--) {
            dp2[i + 1][j + 1] = min(dp2[i + 1][j + 1], dp2[i][j] + b[order[n - 1 - i]]);
        }
    }
    vector<int> c1(n + 1);
    for (int i = 0; i <= n; i++) {
        for (int j = i; j >= 0; j--) {
            if (dp1[i][j] <= x) {
                c1[i] = j;
                break;
            }
        }
    }
    vector<int> c2(n + 1);
    for (int i = 0; i <= n; i++) {
        for (int j = i; j >= 0; j--) {
            if (dp2[i][j] <= y) {
                c2[i] = j;
                break;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        ans = max(ans, c1[i] + c2[n - i]);
    }
    return ans;
}

#ifdef tabr
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << find_maximum_unique(2, 3, {2, 1, 4}, {2, 3, 2}) << '\n';
    cout << find_maximum_unique(6, 12, {5, 1, 5, 6, 3}, {3, 5, 4, 6, 7}) << '\n';

    return 0;
}
#endif
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 288 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 292 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Incorrect 0 ms 204 KB 1st lines differ - on the 1st token, expected: '7', found: '6'
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 288 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 292 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Incorrect 0 ms 204 KB 1st lines differ - on the 1st token, expected: '7', found: '6'
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 30120 KB 1st lines differ - on the 1st token, expected: '689', found: '683'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 29736 KB Output is correct
2 Correct 23 ms 31308 KB Output is correct
3 Correct 28 ms 31580 KB Output is correct
4 Correct 21 ms 28876 KB Output is correct
5 Correct 24 ms 31080 KB Output is correct
6 Correct 22 ms 28836 KB Output is correct
7 Correct 24 ms 30704 KB Output is correct
8 Correct 23 ms 29084 KB Output is correct
9 Correct 21 ms 29068 KB Output is correct
10 Correct 21 ms 29916 KB Output is correct
11 Correct 23 ms 30284 KB Output is correct
12 Correct 23 ms 28804 KB Output is correct
13 Correct 24 ms 30660 KB Output is correct
14 Correct 21 ms 29872 KB Output is correct
15 Correct 22 ms 30124 KB Output is correct
16 Correct 22 ms 29408 KB Output is correct
17 Correct 25 ms 31816 KB Output is correct
18 Correct 22 ms 28812 KB Output is correct
19 Correct 22 ms 30156 KB Output is correct
20 Correct 22 ms 30512 KB Output is correct
21 Correct 23 ms 29844 KB Output is correct
22 Correct 24 ms 31200 KB Output is correct
23 Correct 24 ms 31448 KB Output is correct
24 Correct 20 ms 28872 KB Output is correct
25 Correct 23 ms 31080 KB Output is correct
26 Correct 22 ms 28828 KB Output is correct
27 Correct 24 ms 30608 KB Output is correct
28 Correct 25 ms 29124 KB Output is correct
29 Correct 21 ms 29076 KB Output is correct
30 Correct 22 ms 29900 KB Output is correct
31 Correct 22 ms 30280 KB Output is correct
32 Correct 22 ms 28804 KB Output is correct
33 Correct 23 ms 30736 KB Output is correct
34 Correct 21 ms 29856 KB Output is correct
35 Correct 22 ms 30192 KB Output is correct
36 Correct 22 ms 29476 KB Output is correct
37 Correct 26 ms 31724 KB Output is correct
38 Correct 23 ms 28820 KB Output is correct
39 Correct 22 ms 30160 KB Output is correct
40 Correct 23 ms 30580 KB Output is correct
41 Correct 24 ms 29772 KB Output is correct
42 Correct 23 ms 31312 KB Output is correct
43 Correct 24 ms 31448 KB Output is correct
44 Correct 20 ms 28876 KB Output is correct
45 Correct 22 ms 31076 KB Output is correct
46 Correct 22 ms 28848 KB Output is correct
47 Correct 28 ms 30608 KB Output is correct
48 Correct 23 ms 29032 KB Output is correct
49 Correct 21 ms 29128 KB Output is correct
50 Correct 21 ms 29872 KB Output is correct
51 Correct 24 ms 30256 KB Output is correct
52 Correct 22 ms 28788 KB Output is correct
53 Correct 26 ms 30668 KB Output is correct
54 Correct 21 ms 29876 KB Output is correct
55 Correct 22 ms 30192 KB Output is correct
56 Correct 22 ms 29484 KB Output is correct
57 Correct 24 ms 31764 KB Output is correct
58 Correct 22 ms 28748 KB Output is correct
59 Correct 23 ms 30124 KB Output is correct
60 Correct 22 ms 30572 KB Output is correct
61 Correct 23 ms 29736 KB Output is correct
62 Correct 24 ms 31308 KB Output is correct
63 Correct 29 ms 31612 KB Output is correct
64 Correct 20 ms 28876 KB Output is correct
65 Correct 22 ms 30968 KB Output is correct
66 Correct 22 ms 28832 KB Output is correct
67 Correct 24 ms 30712 KB Output is correct
68 Correct 22 ms 29124 KB Output is correct
69 Correct 21 ms 29072 KB Output is correct
70 Correct 21 ms 29940 KB Output is correct
71 Correct 23 ms 30256 KB Output is correct
72 Correct 23 ms 28764 KB Output is correct
73 Correct 24 ms 30668 KB Output is correct
74 Correct 25 ms 30028 KB Output is correct
75 Correct 22 ms 30156 KB Output is correct
76 Correct 22 ms 29388 KB Output is correct
77 Correct 25 ms 31692 KB Output is correct
78 Correct 22 ms 28812 KB Output is correct
79 Correct 22 ms 30284 KB Output is correct
80 Correct 22 ms 30480 KB Output is correct
81 Correct 23 ms 29772 KB Output is correct
82 Correct 24 ms 31328 KB Output is correct
83 Correct 25 ms 31540 KB Output is correct
84 Correct 20 ms 28876 KB Output is correct
85 Correct 22 ms 31052 KB Output is correct
86 Correct 23 ms 28864 KB Output is correct
87 Correct 25 ms 30624 KB Output is correct
88 Correct 23 ms 29108 KB Output is correct
89 Correct 20 ms 29044 KB Output is correct
90 Correct 21 ms 29872 KB Output is correct
91 Correct 24 ms 30284 KB Output is correct
92 Correct 22 ms 28748 KB Output is correct
93 Correct 24 ms 30664 KB Output is correct
94 Correct 21 ms 29876 KB Output is correct
95 Correct 22 ms 30136 KB Output is correct
96 Correct 22 ms 29436 KB Output is correct
97 Correct 26 ms 31744 KB Output is correct
98 Correct 23 ms 28872 KB Output is correct
99 Correct 22 ms 30156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 30512 KB Output is correct
2 Correct 23 ms 29132 KB Output is correct
3 Correct 23 ms 30668 KB Output is correct
4 Correct 21 ms 30412 KB Output is correct
5 Correct 20 ms 28748 KB Output is correct
6 Correct 24 ms 30536 KB Output is correct
7 Correct 24 ms 31336 KB Output is correct
8 Correct 22 ms 28996 KB Output is correct
9 Correct 22 ms 30640 KB Output is correct
10 Correct 22 ms 31556 KB Output is correct
11 Correct 22 ms 28948 KB Output is correct
12 Correct 23 ms 30192 KB Output is correct
13 Correct 22 ms 29132 KB Output is correct
14 Correct 22 ms 30764 KB Output is correct
15 Correct 21 ms 29376 KB Output is correct
16 Correct 23 ms 29132 KB Output is correct
17 Correct 25 ms 31548 KB Output is correct
18 Correct 27 ms 31512 KB Output is correct
19 Correct 23 ms 30924 KB Output is correct
20 Correct 24 ms 31532 KB Output is correct
21 Correct 24 ms 30540 KB Output is correct
22 Correct 23 ms 29096 KB Output is correct
23 Correct 24 ms 30612 KB Output is correct
24 Correct 22 ms 30380 KB Output is correct
25 Correct 21 ms 28748 KB Output is correct
26 Correct 24 ms 30480 KB Output is correct
27 Correct 24 ms 31244 KB Output is correct
28 Correct 22 ms 28996 KB Output is correct
29 Correct 21 ms 30676 KB Output is correct
30 Correct 23 ms 31460 KB Output is correct
31 Correct 23 ms 28932 KB Output is correct
32 Correct 24 ms 30144 KB Output is correct
33 Correct 25 ms 29224 KB Output is correct
34 Correct 22 ms 30796 KB Output is correct
35 Correct 23 ms 29436 KB Output is correct
36 Correct 22 ms 29132 KB Output is correct
37 Correct 24 ms 31532 KB Output is correct
38 Correct 25 ms 31392 KB Output is correct
39 Correct 23 ms 30892 KB Output is correct
40 Correct 24 ms 31436 KB Output is correct
41 Correct 23 ms 30548 KB Output is correct
42 Correct 22 ms 29104 KB Output is correct
43 Correct 23 ms 30668 KB Output is correct
44 Correct 22 ms 30384 KB Output is correct
45 Correct 20 ms 28684 KB Output is correct
46 Correct 24 ms 30540 KB Output is correct
47 Correct 24 ms 31264 KB Output is correct
48 Correct 22 ms 28972 KB Output is correct
49 Correct 21 ms 30668 KB Output is correct
50 Correct 22 ms 31580 KB Output is correct
51 Correct 23 ms 29004 KB Output is correct
52 Correct 24 ms 30188 KB Output is correct
53 Correct 22 ms 29128 KB Output is correct
54 Correct 23 ms 30788 KB Output is correct
55 Correct 21 ms 29388 KB Output is correct
56 Correct 22 ms 29164 KB Output is correct
57 Correct 24 ms 31560 KB Output is correct
58 Correct 24 ms 31392 KB Output is correct
59 Correct 23 ms 30924 KB Output is correct
60 Correct 23 ms 31520 KB Output is correct
61 Correct 24 ms 30540 KB Output is correct
62 Correct 22 ms 29048 KB Output is correct
63 Correct 24 ms 30640 KB Output is correct
64 Correct 21 ms 30456 KB Output is correct
65 Correct 20 ms 28768 KB Output is correct
66 Correct 23 ms 30576 KB Output is correct
67 Correct 24 ms 31280 KB Output is correct
68 Correct 23 ms 29004 KB Output is correct
69 Correct 21 ms 30668 KB Output is correct
70 Correct 23 ms 31588 KB Output is correct
71 Correct 25 ms 28980 KB Output is correct
72 Correct 23 ms 30116 KB Output is correct
73 Correct 24 ms 29220 KB Output is correct
74 Correct 23 ms 30832 KB Output is correct
75 Correct 22 ms 29388 KB Output is correct
76 Correct 23 ms 29132 KB Output is correct
77 Correct 24 ms 31472 KB Output is correct
78 Correct 24 ms 31416 KB Output is correct
79 Correct 23 ms 30924 KB Output is correct
80 Correct 25 ms 31472 KB Output is correct
81 Correct 23 ms 30468 KB Output is correct
82 Correct 22 ms 29124 KB Output is correct
83 Correct 24 ms 30596 KB Output is correct
84 Correct 24 ms 30388 KB Output is correct
85 Correct 20 ms 28748 KB Output is correct
86 Correct 23 ms 30576 KB Output is correct
87 Correct 24 ms 31308 KB Output is correct
88 Correct 22 ms 29004 KB Output is correct
89 Correct 22 ms 30636 KB Output is correct
90 Correct 23 ms 31476 KB Output is correct
91 Correct 23 ms 28888 KB Output is correct
92 Correct 23 ms 30120 KB Output is correct
93 Correct 22 ms 29236 KB Output is correct
94 Correct 22 ms 30796 KB Output is correct
95 Correct 22 ms 29432 KB Output is correct
96 Correct 24 ms 29124 KB Output is correct
97 Correct 25 ms 31684 KB Output is correct
98 Correct 24 ms 31436 KB Output is correct
99 Correct 23 ms 30924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 288 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 292 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Incorrect 0 ms 204 KB 1st lines differ - on the 1st token, expected: '7', found: '6'
22 Halted 0 ms 0 KB -