Submission #1038581

#TimeUsernameProblemLanguageResultExecution timeMemory
103858112345678Uplifting Excursion (BOI22_vault)C++17
0 / 100
5037 ms15964 KiB
#include <bits/stdc++.h> using namespace std; const int nx=2e6+5, c=1e6; #define ll long long ll m, a[nx], z, p[nx], n[nx], dp[nx], l; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>m>>l; for (int i=m; i>=1; i--) cin>>n[i]; cin>>z; for (int i=1; i<=m; i++) cin>>p[i]; for (int i=0; i<nx; i++) dp[i]=-1; dp[c]=0; for (int i=1; i<=m; i++) { for (int t=0; t<n[i]; t++) for (int j=0; j<nx; j++) if (j+i<nx&&dp[j+i]!=-1) dp[j]=max(dp[j], dp[j+i]+1); } for (int i=1; i<=m; i++) { for (int t=0; t<p[i]; t++) for (int j=nx-1; j>=0; j--) if (j-i>=0&&dp[j-i]!=-1) dp[j]=max(dp[j], dp[j-i]+1); } if (dp[l+c]==-1) cout<<"imposslble"; else cout<<dp[l+c]+z; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...