神秘 CF Div.3 C
  • 板块灌水区
  • 楼主ARIS1_0
  • 当前回复2
  • 已保存回复2
  • 发布时间2025/1/20 10:36
  • 上次更新2025/1/20 11:02:34
查看原帖
神秘 CF Div.3 C
846661
ARIS1_0楼主2025/1/20 10:36

好像和题解做法一模一样,怎么会挂?

#include<bits/stdc++.h>
#define ll long long
using namespace std;
mt19937 myrand(time(0));
inline ll read(){
	ll x=0,w=1;
	char ch=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	return x*w;
}
void write(ll x){
	if(x<0){
		putchar('-');
		x=-x;
	}
	static int sta[35];
	int top=0;
	do{
		sta[top++]=x%10,x/=10;
	}while(x);
	while(top)putchar(sta[--top]+'0');
}
int n,k,sc,a[200005];
int vis[200005];
inline void _(){
	sc=0;
	memset(vis,0,sizeof(vis));
	n=read();k=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		vis[a[i]]++;
	}
	//论我能在div.2切D,可是切不了div.3 C这件事
	for(int i=1;i<=k/2;i++){
		if(k!=i*2){
			sc+=min(vis[i],vis[k-i]);
		}else if(k==i*2){
			sc+=vis[i]/2;
		}
	}
	write(sc);puts("");
}
int t;
int main(){
	t=read();
	while(t--)_();
	return 0;
}
2025/1/20 10:36
加载中...