QOJ.ac

QOJ

IDSubmission IDProblemHackerOwnerResultSubmit timeJudge time
#470#216314#21792. 【NOIP Round #6】抉择Focalors__f0r_1_1n_ran9e__Failed.2023-11-30 10:07:042023-11-30 10:07:04

Details

Extra Test:

Accepted
time: 0ms
memory: 3456kb

input:

1
10

output:

0

result:

ok 1 number(s): "0"

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#216314#21792. 【NOIP Round #6】抉择__f0r_1_1n_ran9e__100 ✓52ms19572kbC++14722b2023-10-15 17:26:322023-10-15 17:26:33

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
int a[1000005], dp[1000005], n, nearexist[45];
inline int max(int x, int y) {
	return (x > y) ? x : y;
}
inline int read() {
	int k = 0;
	char c = getchar();
	while(c < '0' || c > '9') {
		c = getchar(); 
	}
	while(c >= '0' && c <= '9') {
		k = (k << 1) + (k << 3) + c - '0';
		c = getchar();
	}
	return k;
}
signed main() {
	n = read();
	for(register int i = 1; i <= n; ++i) {
		a[i] = read();
		for(register int j = 0; j <= 40; ++j) {
			dp[i] = max(dp[i], dp[nearexist[j]] + (a[nearexist[j]] & a[i]));
		}
		if(a[i]) {
			nearexist[__lg(a[i])] = i;
		}
	}
	printf("%lld", *max_element(dp + 1, dp + n + 1));
	return 0;
}