Submission #660802

#TimeUsernameProblemLanguageResultExecution timeMemory
660802NiyaBali Sculptures (APIO15_sculpture)C++14
0 / 100
17 ms33128 KiB
#include<bits/stdc++.h> using namespace std; const long long maxn = 2048; long long n,a,b; long long age[maxn]; long long par[maxn]; long long dp[maxn][maxn]; void read() { cin >> n >> a >> b; for( long long i = 1; i <= n; i ++ ) cin >> age[i]; } void solve() { memset(dp,-1,sizeof(dp)); for( long long i = 1; i <= n; i ++ ) par[i] = par[i-1] + age[i]; for( long long i = 1; i <= n; i ++ ) dp[i][1] = par[i]; for( long long j = 2; j <= b; j ++ ) { for( long long i = j; i <= n; i ++ ) { for( long long k = i; k > j-1; k -- ) { long long x = ( dp[k-1][j-1] | ( par[i] - par[k-1] ) ); if( dp[i][j] == -1 || x < dp[i][j] ) dp[i][j] = x; } } } long long ans = -1; for( long long i = a; i <= b; i ++ ) if( ans == -1 || dp[n][i] < ans ) ans = dp[n][i]; cout << ans << '\n'; } int main() { read(); solve(); return 0; } /* 6 1 3 8 1 2 1 5 4 */
#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...