제출 #32260

#제출 시각아이디문제언어결과실행 시간메모리
32260cscandkswonBali Sculptures (APIO15_sculpture)C++14
50 / 100
106 ms1144 KiB
#include <cstdio>
const int MAXN = 2005, INF=1e9;
typedef long long ll;

int N, A, B;
ll T;
int Y[MAXN], DP[MAXN];
ll S[MAXN];

int check(ll n) {
	int i, j;
	for (i = 1; i <= N; i++) DP[i] = INF;
	for (i = 1; i <= N; i++) {
		for (j = 0; j < i; j++) {
			if (DP[i] < DP[j] + 1) continue;
			if (((S[i] - S[j]) | n) == n) DP[i] = DP[j] + 1;
		}
	}
	if (DP[N] <= B) return 0;
	return 1;
}

int main() {
	int i;
	scanf("%d %d %d", &N, &A, &B);
	for (i = 1; i <= N; i++) scanf("%d", Y + i);
	if (A != 1) return 0;
	for (i = 1; i <= N; i++) S[i] = S[i - 1] + Y[i];
	for (i = 50; i >= 0; i--) {
		if (check(T + (1LL << i) - 1)) {
			T += (1LL << i);
		}
	}
	printf("%lld", T);
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

sculpture.cpp: In function 'int main()':
sculpture.cpp:25:31: 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:26:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i = 1; i <= N; i++) scanf("%d", Y + i);
                                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...