QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#640465 | #1086. Bank Security Unification | Day_Tao | RE | 0ms | 0kb | C++14 | 1.3kb | 2024-10-14 13:02:18 | 2024-10-14 13:02:20 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ull unsigned long long
#define pii pair<int,int>
#define mid ((l+r)>>1)
#define fi first
#define se second
#define SZ(a) ((int)(a).size())
#define END(a) (prev((a).end()))
#define pc(a) putchar(a)
#define pb(a) push_back(a)
#define no return puts("NO"),void()
#define yes return puts("YES"),void()
typedef long long ll;
const int N = 1e6+5;
const int mod = 998244353;
const ll INFLL = LONG_LONG_MAX;
const int INF = INT_MAX;
inline void cmax(int&a,int b){a=max(a,b);}
inline void cmin(int&a,int b){a=min(a,b);}
inline void add(int&a,int b){a+=b;if(a>=mod)a-=mod;}
inline int read()
{
int x=0,y=1;char c=getchar();
for(;c<'0'||c>'9';c=getchar())if(c=='-')y=-1;
for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+(c^48);
return x*y;
}
int n,a[N],f[N],ans,mx,g[N];
inline void SOLVE()
{
n=read();for(int i=1;i<=n;i++)a[i]=read();
for(int i=1;i<=63;i++)if(a[1]&(1ll<<i))g[i]=1;
for(int i=2;i<=n;i++)
{
f[i]=mx;
for(int j=63;~j;j--)if(a[i]&(1ll<<j))cmax(f[i],f[g[j]]+(a[i]&a[g[j]])),g[j]=i;
cmax(mx,f[i]);
}
printf("%lld\n",mx);
return ;
}
signed main()
{
freopen("rose.in","r",stdin);
freopen("rose.out","w",stdout);
int T=1;while(T--) SOLVE();return 0;
}
详细
Test #1:
score: 0
Dangerous Syscalls
input:
5 1 2 3 1 3