QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#471 | #216314 | #21792. 【NOIP Round #6】抉择 | Focalors | __f0r_1_1n_ran9e__ | Failed. | 2023-11-30 10:08:04 | 2023-11-30 10:08:04 |
Details
Extra Test:
Accepted
time: 1ms
memory: 3512kb
input:
1 10
output:
0
result:
ok 1 number(s): "0"
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#216314 | #21792. 【NOIP Round #6】抉择 | __f0r_1_1n_ran9e__ | 100 ✓ | 52ms | 19572kb | C++14 | 722b | 2023-10-15 17:26:32 | 2023-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;
}