Submission #602882

# Submission time Handle Problem Language Result Execution time Memory
602882 2022-07-23T12:16:46 Z Fidan Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=(1e18)+10;
int main(){
	ll n, a, b, i, j, h;
	cin>>n>>a>>b;
	vector<ll> v(n+1, 0);
	for(i=1; i<=n; i++){
		cin>>v[i];
	}
	if(n==1){
		cout<<v[0];
		return 0;
	}
	if(b==1){
		ll sum=0;
		for(i=1; i<=n; i++){
			sum+=v[i];
		}
		cout<<sum;
		return 0;
	}
	vector<vector<ll>> dp(n+1, vector<ll>(b+1, inf));
	vector<ll> pre(n+1, 0);
	for(i=1; i<=n; i++){
		pre[i]=pre[i-1]+v[i];
	}
	for(i=1; i<=n; i++){
		dp[i][1]=pre[i];
	}
	for(i=1; i<=n; i++){
		for(j=2; j<=b; j++){
			for(h=1; h<i; h++){
				if(dp[h][j-1]==inf) continue;
				dp[i][j]=min(dp[i][j], (dp[h][j-1] | (pre[i]-pre[h])));
			}
		}
	}
	ll mn=inf;
	for(i=1; i<=b; i++) mn=min(mn, dp[n][i]);
	cout<<mn;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 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 0 ms 212 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 212 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 0 ms 212 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 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -