답안 #33722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
33722 2017-11-01T07:14:47 Z sinhriv Bali Sculptures (APIO15_sculpture) C++14
0 / 100
0 ms 33916 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 2020;

int n, a, b;

int arr[N];
long long sum[N];
long long f[N][N];



int main(){
	if(fopen("1.inp", "r")){
		freopen("1.inp", "r", stdin);
	}

	cin >> n >> a >> b;

	for(int i = 1; i <= n; ++i){
		cin >> arr[i];
		sum[i] = arr[i] + sum[i - 1];
		
		f[i][1] = sum[i];
	}



	for(int i = 2; i <= n; ++i){
		for(int j = 2; j <= i; ++j){
			f[i][j] = sum[i];
			for(int k = i - 1; k >= j - 1; --k){
				f[i][j] = min(f[i][j], f[k][j - 1] | (sum[i] - sum[k]));
			}
		}
	}


	long long ans = sum[n];


	for(int i = a; i <= b; ++i){
		ans = min(ans, f[n][i]);
	}

	cout << ans;

	return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:17:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen("1.inp", "r", stdin);
                               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 33916 KB Output is correct
2 Incorrect 0 ms 33916 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 33916 KB Output is correct
2 Incorrect 0 ms 33916 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 33916 KB Output is correct
2 Incorrect 0 ms 33916 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 33916 KB Output is correct
2 Incorrect 0 ms 33916 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 33916 KB Output is correct
2 Incorrect 0 ms 33916 KB Output isn't correct
3 Halted 0 ms 0 KB -