Submission #849936

# Submission time Handle Problem Language Result Execution time Memory
849936 2023-09-15T14:54:53 Z Ahmed57 Uplifting Excursion (BOI22_vault) C++17
0 / 100
72 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
long long dp[101][1000001],arr[301],br = 5e5,n,m;
long long solve(int i,int xd){
    if(i==2*m+1){
        if(xd==n+br)return 0;
        else return -1e18;
    }
    if(dp[i][xd]!=-1)return dp[i][xd];
    long long ans = -1e18;
    for(int j = 0;j<=arr[i];j++){
        ans = max(ans,solve(i+1,xd+j*(i-m))+j);
    }
    return dp[i][xd] = ans;
}
signed main(){
    cin>>m>>n;
    for(int i = 0;i<2*m+1;i++){
        cin>>arr[i];
    }
    memset(dp,-1,sizeof dp);
    long long vl = solve(0,5e5);
    if(vl<0)cout<<"impossible\n";
    else cout<<vl<<endl;
}
# Verdict Execution time Memory Grader output
1 Runtime error 72 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 72 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 65 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 65 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 65 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 72 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 65 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 72 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 65 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 72 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -