记录编号 |
577642 |
评测结果 |
AAAAAAAAAAAA |
题目名称 |
界外科学 |
最终得分 |
100 |
用户昵称 |
op_组撒头屯 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
9.534 s |
提交时间 |
2022-11-18 17:26:24 |
内存使用 |
5.74 MiB |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=36+5;
int n,m;
ll ans=0;
struct sdf{
ll a,b;
}q[N];
ll calc(){
ll nowa=0,nowb=0,mx=0;
for (int i=1;i<=n;i++){
if (nowb+q[i].b<0)continue;
nowa^=q[i].a;nowb+=q[i].b;
if (nowa<=m)mx=max(mx,nowb);
}
ans=max(ans,mx);
return mx;
}
void SA(){
double t=1e5;
while(t>0.001){
int x=rand()%n+1,y=rand()%n+1;
swap(q[x],q[y]);
ll now=calc();
if (now<ans){
ll d=ans-now;
if (exp(-1.0*d/t)<rand())swap(q[x],q[y]);
}
t*=0.99;
}
for (int i=1;i<=1000;i++){
int x=rand()%n+1,y=rand()%n+1;
swap(q[x],q[y]);
calc();
swap(q[x],q[y]);
}
return ;
}
int main(){
freopen ("outsci.in","r",stdin);
freopen ("outsci.out","w",stdout);
scanf("%d%d",&n,&m);
srand(time(0));
for (int i=1;i<=n;i++)scanf("%lld",&q[i].a);
for (int i=1;i<=n;i++)scanf("%lld",&q[i].b);
while((double)clock()/CLOCKS_PER_SEC<=0.85)SA();
printf("%lld\n",ans);
return 0;
}