rt
代码:
#include<bits/stdc++.h>
using namespace std;
#define N 200007
int a[N];
int c[N];
pair<int,int> last[N];
int n,T;
int main(){
cin>>T;
while(T--){
cin>>n;
for(int i=0;i<n;++i){
cin>>a[i];
}
int ans=0;
for(int i=0;i<(1<<n);++i){
for(int j=0;j<n;++j){
if(i>>j&1){
c[j]=1;
}
else{
c[j]=0;
}
}
int ll[]={2e9,2e9};
int ct=0;
for(int j=0;j<n;++j){
if(ll[c[j]]!=2e9){
if(a[ll[c[j]]]==a[j]) ct+=a[j];
}
ll[c[j]]=j;
}
ans=max(ans,ct);
}
cout<<ans<<'\n';
}
return 0;
}
我在代码上写了游记。
然后我发现这个代码过不了编译。。。
而且本地是可以过的。(学校的windows神机)