답안 #25009

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25009 2017-06-20T03:42:31 Z kdh9949 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
0 ms 3620 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll inf = 1e18;
int n, a, b;
ll s[2010], dp[101][2010], ans = inf;

int main(){
	scanf("%d%d%d", &n, &a, &b);
	for(int i = 1; i <= n; i++){ scanf("%lld", s + i); s[i] += s[i - 1]; }
	if(n <= 100){
		fill(dp[0] + 1, dp[0] + n + 1, inf);
		for(int i = 1; i <= b; i++){
			for(int j = i; j <= n; j++){
				dp[i][j] = inf;
				for(int k = i - 1; k < j; k++){
					dp[i][j] = min(dp[i][j], dp[i - 1][k] | (s[j] - s[k]));
				}
			}
		}
		for(int i = a; i <= b; i++) ans = min(ans, dp[i][n]);
		printf("%lld\n", ans);
	}
	else{
		for(int i = 1; i <= n; i++){
			dp[0][i] = inf;
			for(int j = 0; j < i; j++){
				dp[0][i] = min(dp[0][i], dp[0][j] | (s[i] - s[j]));
			}
		}
		printf("%lld\n", dp[0][n]);
	}
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:10:29: 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:11:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i <= n; i++){ scanf("%lld", s + i); s[i] += s[i - 1]; }
                                                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3620 KB Output is correct
2 Incorrect 0 ms 3620 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3620 KB Output is correct
2 Incorrect 0 ms 3620 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3620 KB Output is correct
2 Incorrect 0 ms 3620 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3620 KB Output is correct
2 Incorrect 0 ms 3620 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3620 KB Output is correct
2 Incorrect 0 ms 3620 KB Output isn't correct
3 Halted 0 ms 0 KB -