답안 #469958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
469958 2021-09-02T12:18:58 Z luciocf Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 2e3+10;
const ll inf = 1e18;

int n;
int a[maxn];

ll pref[maxn];

ll dp[maxn][maxn];

int main(void)
{
	int A, B;
	scanf("%d %d %d", &n, &A, &B);

	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);

		pref[i] = pref[i-1] + 1ll*a[i]; 
	}

	for (int i = 0; i <= n; i++)
		for (int j = 1; j <= n; j++)
			dp[i][j] = inf;

	for (int k = 1; k <= n; k++)
		for (int i = 1; i <= n; i++)
			for (int j = i; j >= 1; j--)
				if ((dp[k-1][j-1] | (pref[i] - pref[j-1])) <= dp[k][i])
					dp[k][i] = (dp[k-1][j-1] | (pref[i] - pref[j-1]));

	ll ans = inf;

	for (int i = A; i <= B; i++)
		ans = min(ans, dp[i][n]);

	printf("%lld\n", ans);
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  scanf("%d %d %d", &n, &A, &B);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf("%d", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -