B
https://cn.vjudge.net/problem/2253291/origin
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1e6+10;
int a[maxn];
int b[maxn];
int main()
{
int n,i,j,k=0,sum=0,ans=0;
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i];
//sort(a+1,a+n+1);
for(i=1;i<=n;i++)
{
for(j=i+1;j<=n;j++)
{
sum=a[i]+a[j];
b[sum]++;
ans=max(ans,sum);
}
}
for(i=0;i<=ans;i++)
{
k=max(k,b[i]);
}
cout<<k<<endl;
return 0;
}
D
https://cn.vjudge.net/problem/2266490/origin
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int main()
{
int n,i,j,num=1,k=0,x=0,ans=1;
memset(a,0,sizeof(a));
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i];
ans=1;
for(i=1;i<n;i++)
{
num=1;
if(a[i]==a[i+1])
{
ans++;
}
else
{
//cout<<ans<<" ans"<<endl;
//cout<<i<<" i"<<endl;
num=1;
for(j=i+1;j<n;j++)
{
if(a[j]==a[j+1])
{
//cout<<a[j]<<a[j+1]<<endl;
num++;
}
else
break;
}
//cout<<num<<" num"<<endl;
k=min(ans,num);
x=max(k,x);
ans=1;
}
}
cout<<x*2<<endl;
return 0;
}
正好赶上这两天心烦气躁 然后我就疯狂爆零了 然后我就发现 我需要冷静 不能慌 一慌就没有耐心了