Submission #788243

# Submission time Handle Problem Language Result Execution time Memory
788243 2023-07-20T03:18:19 Z Ozy Uplifting Excursion (BOI22_vault) C++17
20 / 100
213 ms 23756 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define pll pair<lli,lli>

#define MAX 1000000

lli m,l,res,ceros,a,b,c;
lli arr[2][102];
lli dp[2][MAX+2], usados[MAX+2], existe[2][MAX+2];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> m >> l;
    repa(i,m,1) cin >> arr[0][i];
    cin >> ceros;
    rep(i,1,m) cin >> arr[1][i];

    rep(id,0,1) {
        existe[id][0] = true;

        rep(i,1,m) {
            rep(j,1,MAX) {
                a = j-i;
                usados[j] = 0;

                if(a < 0) continue;
                if (!existe[id][a]) continue;
                if (usados[a] == arr[id][i]) continue; //podrai hacer un berak? segun yo no

                b = dp[id][a]+1;
                if (b > dp[id][j]) {
                    existe[id][j] = 1;
                    usados[j] = usados[a]+1;
                    dp[id][j] = b;
                }
            }
        }

    }

    //rep(id,0,1) {
    //    debug(id);
    //    rep(i,0,15) {
    //        debugsl(i);
    //        debugsl(existe[id][i]);
    //        debug(dp[id][i]);
    //    }
    //}

    res = -1;
    a = 0;
    b = 0;
    if (l < 0) a = -l;
    else b = l;

    rep(i,0,MAX) {
        if( (a+i) > MAX || (b+i) > MAX) break;

        if(!existe[0][i+a] || !existe[1][i+b]) continue;

        c = dp[0][i+a] + dp[1][i+b];
        res = max(res,c);
    }

    if(res == -1) {
        cout << "impossible";
        return 0;
    }

    res += ceros;
    if(res == 0) cout << "impossible";
    else cout << res;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8148 KB Output is correct
2 Correct 10 ms 8148 KB Output is correct
3 Correct 8 ms 8148 KB Output is correct
4 Correct 20 ms 8200 KB Output is correct
5 Correct 78 ms 9116 KB Output is correct
6 Correct 87 ms 9216 KB Output is correct
7 Correct 85 ms 8592 KB Output is correct
8 Correct 102 ms 9112 KB Output is correct
9 Correct 83 ms 9964 KB Output is correct
10 Correct 78 ms 8176 KB Output is correct
11 Correct 95 ms 8288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8148 KB Output is correct
2 Correct 10 ms 8148 KB Output is correct
3 Correct 8 ms 8148 KB Output is correct
4 Correct 20 ms 8200 KB Output is correct
5 Correct 78 ms 9116 KB Output is correct
6 Correct 87 ms 9216 KB Output is correct
7 Correct 85 ms 8592 KB Output is correct
8 Correct 102 ms 9112 KB Output is correct
9 Correct 83 ms 9964 KB Output is correct
10 Correct 78 ms 8176 KB Output is correct
11 Correct 95 ms 8288 KB Output is correct
12 Correct 9 ms 8196 KB Output is correct
13 Correct 12 ms 8148 KB Output is correct
14 Correct 7 ms 8148 KB Output is correct
15 Correct 20 ms 8148 KB Output is correct
16 Correct 80 ms 9092 KB Output is correct
17 Correct 80 ms 9120 KB Output is correct
18 Correct 80 ms 8516 KB Output is correct
19 Correct 89 ms 9164 KB Output is correct
20 Correct 79 ms 9964 KB Output is correct
21 Correct 78 ms 8172 KB Output is correct
22 Correct 79 ms 8148 KB Output is correct
23 Correct 168 ms 16044 KB Output is correct
24 Correct 171 ms 16124 KB Output is correct
25 Correct 161 ms 11416 KB Output is correct
26 Correct 193 ms 23488 KB Output is correct
27 Correct 213 ms 23464 KB Output is correct
28 Correct 147 ms 8432 KB Output is correct
29 Correct 151 ms 8432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 8176 KB Output is correct
2 Incorrect 79 ms 23756 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 8176 KB Output is correct
2 Incorrect 79 ms 23756 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 8176 KB Output is correct
2 Incorrect 79 ms 23756 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8148 KB Output is correct
2 Correct 10 ms 8148 KB Output is correct
3 Correct 8 ms 8148 KB Output is correct
4 Correct 20 ms 8200 KB Output is correct
5 Correct 78 ms 9116 KB Output is correct
6 Correct 87 ms 9216 KB Output is correct
7 Correct 85 ms 8592 KB Output is correct
8 Correct 102 ms 9112 KB Output is correct
9 Correct 83 ms 9964 KB Output is correct
10 Correct 78 ms 8176 KB Output is correct
11 Correct 95 ms 8288 KB Output is correct
12 Correct 26 ms 8176 KB Output is correct
13 Incorrect 79 ms 23756 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 8176 KB Output is correct
2 Incorrect 79 ms 23756 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8148 KB Output is correct
2 Correct 10 ms 8148 KB Output is correct
3 Correct 8 ms 8148 KB Output is correct
4 Correct 20 ms 8200 KB Output is correct
5 Correct 78 ms 9116 KB Output is correct
6 Correct 87 ms 9216 KB Output is correct
7 Correct 85 ms 8592 KB Output is correct
8 Correct 102 ms 9112 KB Output is correct
9 Correct 83 ms 9964 KB Output is correct
10 Correct 78 ms 8176 KB Output is correct
11 Correct 95 ms 8288 KB Output is correct
12 Correct 9 ms 8196 KB Output is correct
13 Correct 12 ms 8148 KB Output is correct
14 Correct 7 ms 8148 KB Output is correct
15 Correct 20 ms 8148 KB Output is correct
16 Correct 80 ms 9092 KB Output is correct
17 Correct 80 ms 9120 KB Output is correct
18 Correct 80 ms 8516 KB Output is correct
19 Correct 89 ms 9164 KB Output is correct
20 Correct 79 ms 9964 KB Output is correct
21 Correct 78 ms 8172 KB Output is correct
22 Correct 79 ms 8148 KB Output is correct
23 Correct 168 ms 16044 KB Output is correct
24 Correct 171 ms 16124 KB Output is correct
25 Correct 161 ms 11416 KB Output is correct
26 Correct 193 ms 23488 KB Output is correct
27 Correct 213 ms 23464 KB Output is correct
28 Correct 147 ms 8432 KB Output is correct
29 Correct 151 ms 8432 KB Output is correct
30 Correct 26 ms 8176 KB Output is correct
31 Incorrect 79 ms 23756 KB Output isn't correct
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 8176 KB Output is correct
2 Incorrect 79 ms 23756 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8148 KB Output is correct
2 Correct 10 ms 8148 KB Output is correct
3 Correct 8 ms 8148 KB Output is correct
4 Correct 20 ms 8200 KB Output is correct
5 Correct 78 ms 9116 KB Output is correct
6 Correct 87 ms 9216 KB Output is correct
7 Correct 85 ms 8592 KB Output is correct
8 Correct 102 ms 9112 KB Output is correct
9 Correct 83 ms 9964 KB Output is correct
10 Correct 78 ms 8176 KB Output is correct
11 Correct 95 ms 8288 KB Output is correct
12 Correct 9 ms 8196 KB Output is correct
13 Correct 12 ms 8148 KB Output is correct
14 Correct 7 ms 8148 KB Output is correct
15 Correct 20 ms 8148 KB Output is correct
16 Correct 80 ms 9092 KB Output is correct
17 Correct 80 ms 9120 KB Output is correct
18 Correct 80 ms 8516 KB Output is correct
19 Correct 89 ms 9164 KB Output is correct
20 Correct 79 ms 9964 KB Output is correct
21 Correct 78 ms 8172 KB Output is correct
22 Correct 79 ms 8148 KB Output is correct
23 Correct 168 ms 16044 KB Output is correct
24 Correct 171 ms 16124 KB Output is correct
25 Correct 161 ms 11416 KB Output is correct
26 Correct 193 ms 23488 KB Output is correct
27 Correct 213 ms 23464 KB Output is correct
28 Correct 147 ms 8432 KB Output is correct
29 Correct 151 ms 8432 KB Output is correct
30 Correct 26 ms 8176 KB Output is correct
31 Incorrect 79 ms 23756 KB Output isn't correct
32 Halted 0 ms 0 KB -