| 比赛 |
收心赛 |
评测结果 |
AAAAAAAAEEEEAAAAEEEE |
| 题目名称 |
异或粽子 |
最终得分 |
60 |
| 用户昵称 |
ChenBp |
运行时间 |
3.844 s |
| 代码语言 |
C++ |
内存使用 |
10.40 MiB |
| 提交时间 |
2026-02-24 11:46:38 |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a[500005],b[1000006];
int main(){
freopen("xor.in","r",stdin);
freopen("xor.out","w",stdout);
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int cnt=0;
for(int i=1;i<=n;i++){
ll now=0;
for(int j=i;j<=n;j++){
now^=a[j];
b[++cnt]=now;
}
}
sort(b+1,b+1+cnt,greater<ll>());
ll ans=0;
for(int i=1;i<=k;i++) {
ans+=b[i];
}
cout<<ans;
return 0;
}