답안 #56531

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56531 2018-07-11T15:05:37 Z leejseo Bali Sculptures (APIO15_sculpture) C++
0 / 100
29 ms 31952 KB
#include <bits/stdc++.h>
using namespace std;

#define UNDEF -1

int L[2001], N, A, B;
long long S[2001], D[2001][2001];

void input(){
	scanf("%d%d%d", &N, &A, &B);	
	memset(D, -1, sizeof(D[0][0])*2001*2001);
	for (int i=1; i<=N; i++){
		scanf("%d", &L[i]);
		S[i] = S[i-1] + L[i];
	}
}

void DP(){
	for (int i=1; i<=N; i++){
		D[i][1] = S[i];
		for (int j=2; j<=i; j++){
			D[i][j] = D[i-1][j-1] | L[i];
			for (int k=1; k<i; k++){
				if (D[k][j-1] != UNDEF) D[i][j] = min(D[i][j], D[k][j-1] | (S[i] - S[k]));
			}
		}
	}
}

int main(void){
	input();
	DP();
	long long ans = (long long)1e15;
	for (int i=A; i<=B; i++) ans = min(ans, D[N][i]);
	printf("%lld\n", ans);
	return 0;
}

Compilation message

sculpture.cpp: In function 'void input()':
sculpture.cpp:10: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:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &L[i]);
   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 31608 KB Output is correct
2 Incorrect 27 ms 31844 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 31844 KB Output is correct
2 Incorrect 29 ms 31844 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 31844 KB Output is correct
2 Incorrect 25 ms 31844 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 31868 KB Output is correct
2 Incorrect 22 ms 31868 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 31952 KB Output is correct
2 Incorrect 23 ms 31952 KB Output isn't correct
3 Halted 0 ms 0 KB -