답안 #101238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101238 2019-03-18T03:31:25 Z arman_ferdous Bali Sculptures (APIO15_sculpture) C++17
0 / 100
37 ms 16212 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const int N = 2010;
int n, A, B;
ll a[N], sum[N], mask, diff;

int dp4[N][N], dp5[N];
int DP4(int pos, int parts) {
	if(pos > n) {
		if(A <= parts && parts <= B) return 1;
		return 0;
	} if(parts > B) return 0;
	if(dp4[pos][parts] != -1) return dp4[pos][parts];

	int &ret = dp4[pos][parts]; ret = 0;
	ll s = 0;
	for(int i = pos; i <= n; i++) {
		s += a[i];
		if((mask ^ s) < diff) ret |= DP4(i+1, parts+1);
	}
	return ret;
}

int main() {
	scanf("%d %d %d", &n, &A, &B);
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		sum[i] = sum[i-1] + a[i];
	}
	if(n <= 100) {
		for(int i = 5; i >= 0; i--) {
			memset(dp4, -1, sizeof dp4);
			diff = (1ll<<i);
			if(!DP4(1,0)) mask |= (1ll<<i);
		}
		printf("%lld\n", mask);
		return 0;
	}
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:27: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:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &a[i]);
   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 16128 KB Output is correct
2 Incorrect 29 ms 16128 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 16128 KB Output is correct
2 Incorrect 37 ms 16120 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 16184 KB Output is correct
2 Incorrect 29 ms 16128 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 16128 KB Output is correct
2 Incorrect 33 ms 16128 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 16212 KB Output is correct
2 Incorrect 34 ms 16096 KB Output isn't correct
3 Halted 0 ms 0 KB -