Submission #612273

# Submission time Handle Problem Language Result Execution time Memory
612273 2022-07-29T12:25:14 Z KrisjanisP Uplifting Excursion (BOI22_vault) C++17
0 / 100
373 ms 23628 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll M = 300;
ll a[2*M+1];

ll m, l;

bool dp_vis[M*2+1][100*M+1];
ll dp_res[M*2+1][100*M+1];

// returns max items that can be picked
ll dp(ll v, ll sum)
{
    if(sum<0) return -1;
    if(sum==0) return 0;
    if(v==m+1) return -1;
    if(dp_vis[v+m][sum])
        return dp_res[v+m][sum];
    dp_vis[v+m][sum] = 1;

    //cout<<v<<" "<<sum<<"\n";
    ll res = -1;
    for(ll i=0;i<=a[v+m];i++)
    {
        ll r = dp(v+1,sum-(v*i));
        if(r==-1) continue;
        res = max(res, r+i);
    }
    dp_res[v+m][sum] = res;
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin>>m>>l;
    for(ll i=-m;i<=m;i++)
        cin>>a[i+m];
    ll r = 1;
    if(l<=M*100)
        r = dp(-m,l);
    if(r==-1) cout<<"impossible\n";
    else cout<<r<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 373 ms 23628 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 373 ms 23628 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 373 ms 23628 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 373 ms 23628 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 373 ms 23628 KB Output isn't correct
7 Halted 0 ms 0 KB -