C. Boats Competition1300 / 思维 暴力

Posted 幽殇默

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C. Boats Competition1300 / 思维 暴力相关的知识,希望对你有一定的参考价值。


https://codeforces.com/problemset/problem/1399/C
数据范围很小直接枚举所有和。

#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;
int a[N],cnt[N],backup[N],t,n;
int main(void)

	cin>>t;
	while(t--)
	
		cin>>n;
		memset(cnt,0,sizeof cnt);
		for(int i=0;i<n;i++) cin>>a[i],cnt[a[i]]++;
		int ans=0;
		for(int i=0;i<=100;i++)//枚举所有的和
		
			memcpy(backup,cnt,sizeof cnt);
			int temp=0;
			for(int j=0;j<n;j++)//枚举所有的数
			
			    if(i==a[j]*2&&backup[a[j]]<2) continue;//如果这俩数相等,且目前的数的个数不足2个
				if(i-a[j]>=0&&backup[i-a[j]]&&backup[a[j]])//如果这俩数都还有
				
				    temp++,backup[i-a[j]]--,backup[a[j]]--;
				
			
			ans=max(ans,temp);
		
		cout<<ans<<endl;
	
	return 0;

以上是关于C. Boats Competition1300 / 思维 暴力的主要内容,如果未能解决你的问题,请参考以下文章

Educational Codeforces Round 55 (Rated for Div. 2) C. Multi-Subject Competition (实现,贪心,排序)

Codeforces 1082 C. Multi-Subject Competition-有点意思 (Educational Codeforces Round 55 (Rated for Div. 2

Educational Codeforces Round 55 (Rated for Div. 2) C. Multi-Subject Competition vector 预处理优化

codeforces Educational Codeforces Round 55 (Rated for Div. 2) C题 C. Multi-Subject Competition

[Educational Codeforces Round 55 (Rated for Div. 2)][C. Multi-Subject Competition][时间复杂度]

C. Registration system1300 / 哈希