92(紫色显眼包1个)
  • 板块P1102 A-B 数对
  • 楼主syy999
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/7/24 12:13
  • 上次更新2024/7/24 14:11:15
查看原帖
92(紫色显眼包1个)
1373929
syy999楼主2024/7/24 12:13
#include<bits/stdc++.h>
using namespace std;
int a[100000001];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,c,x;
	cin>>n>>c;
	for(int i=1;i<=n;i++){
		cin>>x;
		a[x]++;
	}
	long long ans=0;
	for(int i=c;i<=pow(10,8);i++){
		if(a[i]&&a[i-c]) ans+=a[i]*a[i-c];
	}
	cout<<ans;
	return 0;
}

2024/7/24 12:13
加载中...