Submission #1192118

#TimeUsernameProblemLanguageResultExecution timeMemory
1192118SofiatpcBali Sculptures (APIO15_sculpture)C++20
16 / 100
18 ms3004 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 55, INF = 1e9; int dp[MAXN][505][25], v[MAXN]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,a,b; cin>>n>>a>>b; int tot = 0; for(int i = 1; i <= n; i++){ cin>>v[i]; tot += v[i]; } for(int o = 0; o <= tot; o++)dp[n+1][o][0] = o; for(int o = 0; o <= tot; o++) for(int x = 1; x <= b; x++)dp[n+1][o][x] = INF; for(int i = n; i >= 1; i--){ for(int o = 0; o <= tot; o++){ dp[i][o][0] = INF; for(int x = 1; x <= b; x++){ dp[i][o][x] = INF; int sum = 0; for(int j = i+1; j <= n+1; j++){ sum += v[j-1]; dp[i][o][x] = min(dp[i][o][x], dp[j][o| sum][x-1] ); } } } } int ans = INF; for(int x = a; x <= b; x++)ans = min(ans, dp[1][0][x]); cout<<ans<<"\n"; }
#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...