Submission #227577

# Submission time Handle Problem Language Result Execution time Memory
227577 2020-04-27T22:08:21 Z tushar_2658 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
5 ms 384 KB
#include "bits/stdc++.h"
using namespace std;

const int maxn = 105;
using ll = long long; 

ll dp[maxn][maxn];
ll a[maxn];

int main(int argc, char const *argv[])
{
//	freopen("in.txt", "r", stdin);
	int n, A, B;
	scanf("%d %d %d", &n, &A, &B);
	for(int i = 1; i <= n; ++i){
		scanf("%lld", &a[i]);
	}
	vector<ll> p(n + 1);
	for(int i = 1; i <= n; ++i){
		p[i] = p[i - 1] + a[i]; 
	}
	memset(dp, 63, sizeof dp);
	dp[0][0] = 0;
	for(int k = 1; k <= B; ++k){
		for(int i = 1; i <= n; ++i){
			for(int j = 0; j < i; ++j){
				dp[i][k] = min(dp[i][k], dp[j][k - 1] | (p[i] - p[j]));
			}
		}
	}
	ll ans = LLONG_MAX;
	for(int i = A; i <= B; ++i){
		ans = min(ans, dp[n][i]);
	}
	cout << ans << endl;

	return 0;
}

Compilation message

sculpture.cpp: In function 'int main(int, const char**)':
sculpture.cpp:14: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:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &a[i]);
   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -