답안 #101240

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101240 2019-03-18T03:49:45 Z arman_ferdous Bali Sculptures (APIO15_sculpture) C++17
0 / 100
2 ms 384 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, bitpos;

int dp4[105][105], 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 >> bitpos) == (s >> bitpos)) 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 <= 110) {
		for(bitpos = 42; bitpos >= 0; bitpos--) {
			memset(dp4, -1, sizeof dp4);
			if(!DP4(1,0)) mask |= (1ll<<bitpos);
		}
		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 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -