Submission #300735

# Submission time Handle Problem Language Result Execution time Memory
300735 2020-09-17T12:52:16 Z rocks03 Jelly Flavours (IOI20_jelly) C++14
0 / 100
1584 ms 2097156 KB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int) (x).size())
using namespace std;

int N;
vector<int> v1, v2;
vector<vector<vector<int>>> memo;
int f(int ind, int b1, int b2){
    if(ind == N){
        return 0;
    }
    if(memo[ind][b1][b2] != -1){
        return memo[ind][b1][b2];
    }
    int ans = 0;
    if(b1 >= v1[ind]){
        ans = max(ans, f(ind + 1, b1 - v1[ind], b2) + 1);
    }
    if(b2 >= v2[ind]){
        ans = max(ans, f(ind + 1, b1, b2 - v2[ind]) + 1);
    }
    ans = max(ans, f(ind + 1, b1, b2));
    memo[ind][b1][b2] = ans;
    return ans;
}

int faster(int B){
    vector<pii> v;
    for(int i = 0; i < N; i++){
        v[i] = {v1[i], v2[i]};
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(v[i].ss == 0){
            ans++;
        } else if(v[i].ff <= B){
            B -= v[i].ff;
            ans++;
        }
    }
    return ans;
}

int find_maximum_unique(int x, int y, vector<int> a, vector<int> b){
    v1 = a;
    v2 = b;
    N = SZ(v1);
    if(y == 0){
        return faster(x);
    }
    memo.resize(N);
    for(int i = 0; i < N; i++){
        memo[i].resize(x+1);
        for(int j = 0; j <= x; j++){
            memo[i][j].resize(y+1);
            for(int k = 0; k <= y; k++)
                memo[i][j][k] = -1;
        }
    }
    return f(0, x, y);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1824 KB Output is correct
2 Correct 6 ms 7168 KB Output is correct
3 Correct 6 ms 7424 KB Output is correct
4 Correct 12 ms 10368 KB Output is correct
5 Correct 7 ms 7936 KB Output is correct
6 Correct 6 ms 6400 KB Output is correct
7 Correct 8 ms 9088 KB Output is correct
8 Correct 5 ms 6272 KB Output is correct
9 Correct 7 ms 8320 KB Output is correct
10 Correct 11 ms 10112 KB Output is correct
11 Correct 1 ms 1152 KB Output is correct
12 Correct 2 ms 1792 KB Output is correct
13 Correct 6 ms 7168 KB Output is correct
14 Correct 6 ms 7424 KB Output is correct
15 Correct 12 ms 10368 KB Output is correct
16 Correct 7 ms 7936 KB Output is correct
17 Correct 6 ms 6400 KB Output is correct
18 Correct 8 ms 9088 KB Output is correct
19 Correct 5 ms 6272 KB Output is correct
20 Correct 8 ms 8320 KB Output is correct
21 Correct 2 ms 1920 KB Output is correct
22 Correct 13 ms 10112 KB Output is correct
23 Correct 2 ms 1920 KB Output is correct
24 Runtime error 1 ms 512 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1824 KB Output is correct
2 Correct 6 ms 7168 KB Output is correct
3 Correct 6 ms 7424 KB Output is correct
4 Correct 12 ms 10368 KB Output is correct
5 Correct 7 ms 7936 KB Output is correct
6 Correct 6 ms 6400 KB Output is correct
7 Correct 8 ms 9088 KB Output is correct
8 Correct 5 ms 6272 KB Output is correct
9 Correct 7 ms 8320 KB Output is correct
10 Correct 11 ms 10112 KB Output is correct
11 Correct 1 ms 1152 KB Output is correct
12 Correct 2 ms 1792 KB Output is correct
13 Correct 6 ms 7168 KB Output is correct
14 Correct 6 ms 7424 KB Output is correct
15 Correct 12 ms 10368 KB Output is correct
16 Correct 7 ms 7936 KB Output is correct
17 Correct 6 ms 6400 KB Output is correct
18 Correct 8 ms 9088 KB Output is correct
19 Correct 5 ms 6272 KB Output is correct
20 Correct 8 ms 8320 KB Output is correct
21 Correct 2 ms 1920 KB Output is correct
22 Correct 13 ms 10112 KB Output is correct
23 Correct 2 ms 1920 KB Output is correct
24 Runtime error 1 ms 512 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1518 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1584 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1824 KB Output is correct
2 Correct 6 ms 7168 KB Output is correct
3 Correct 6 ms 7424 KB Output is correct
4 Correct 12 ms 10368 KB Output is correct
5 Correct 7 ms 7936 KB Output is correct
6 Correct 6 ms 6400 KB Output is correct
7 Correct 8 ms 9088 KB Output is correct
8 Correct 5 ms 6272 KB Output is correct
9 Correct 7 ms 8320 KB Output is correct
10 Correct 11 ms 10112 KB Output is correct
11 Correct 1 ms 1152 KB Output is correct
12 Correct 2 ms 1792 KB Output is correct
13 Correct 6 ms 7168 KB Output is correct
14 Correct 6 ms 7424 KB Output is correct
15 Correct 12 ms 10368 KB Output is correct
16 Correct 7 ms 7936 KB Output is correct
17 Correct 6 ms 6400 KB Output is correct
18 Correct 8 ms 9088 KB Output is correct
19 Correct 5 ms 6272 KB Output is correct
20 Correct 8 ms 8320 KB Output is correct
21 Correct 2 ms 1920 KB Output is correct
22 Correct 13 ms 10112 KB Output is correct
23 Correct 2 ms 1920 KB Output is correct
24 Runtime error 1 ms 512 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -