Submission #185638

# Submission time Handle Problem Language Result Execution time Memory
185638 2020-01-12T02:38:17 Z dndhk Bali Sculptures (APIO15_sculpture) C++14
0 / 100
3 ms 376 KB
#include <bits/stdc++.h>

#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX_N = 100;
const int INF = 10000000;

int N, A, B;
vector<ll> v;
ll dp[MAX_N+1][MAX_N+1];
ll ans;

ll sum(ll x, ll y){
	return dp[1][y] - dp[1][x-1];
}

int main(){
	scanf("%d%d%d", &N, &A, &B);
	v.pb(0LL);
	for(int i=1 ;i<=N; i++){
		ll x; scanf("%lld", &x);
		v.pb(x);
	}
	for(int i=1; i<=N; i++){
		dp[1][i] = dp[1][i-1] + v[i];
	}
	for(int k=2; k<=N; k++){
		for(int i=k; i<=N; i++){
			dp[k][i] = (v[i] | dp[k-1][i-1]);
			for(int j=i-1; j>=k-1; j--){
				dp[k][i] = min(dp[k][i], (sum(j, i) | dp[k-1][j-1]));
			}
			//cout<<k<<" "<<i<<" "<<dp[k][i]<<endl;
		}
	}
	ans = dp[A][N];
	for(int i=A; i<=B; i++){
		ans = min(ans, dp[i][N]);
	}
	cout<<ans;
	return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &N, &A, &B);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   ll x; scanf("%lld", &x);
         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -