Submission #787425

# Submission time Handle Problem Language Result Execution time Memory
787425 2023-07-19T07:30:21 Z acatmeowmeow Bali Sculptures (APIO15_sculpture) C++11
0 / 100
5 ms 324 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long 

namespace sub4 {

	const int N = 100;
	int prefix[N + 5];
	bool dp[N + 5][N + 5];
	int ans = 0;

	void main(int n, int a, int b, int arr[]) {
		for (int i = 1; i <= n; i++) prefix[i] = prefix[i - 1] + arr[i];
		for (int bit = 40; bit >= 0; bit--) {

			for (int i = 0; i <= n; i++) {
				for (int j = 0; j <= n; j++) {
					dp[i][j] = false;
				}
			}

			dp[0][0] = true;
			
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= i; k++) {
						int v = prefix[i] - prefix[k - 1];
						if ((v >> bit) != (ans >> bit)) continue;
						dp[i][j] |= dp[k - 1][j - 1];
					}
				}
			}

			bool valid = false;
			for (int j = a; j <= b; j++) valid |= dp[n][j];
			if (!valid) ans ^= (1ll << bit);
		}		
		cout << ans << '\n';
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, a, b;
	cin >> n >> a >> b;
	int arr[n + 5];
	for (int i = 1; i <= n; i++)cin >> arr[i];
	sub4::main(n, a, b, arr);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 5 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -