求助
  • 板块P1102 A-B 数对
  • 楼主zxyall
  • 当前回复13
  • 已保存回复13
  • 发布时间2023/10/12 17:58
  • 上次更新2023/11/2 14:17:19
查看原帖
求助
1067001
zxyall楼主2023/10/12 17:58

为什么用map可以AC,用unordered_map全wa???

#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
#define int long long
const int N = 1e5+10;
map<int,int>m;
int n,c;

signed main(){
	cin>>n>>c;
	
	for(int i=0;i<n;i++){
		int x;scanf("%lld",&x);
		m[x]++;
	}
	int res=0;
	for(auto x:m){
		res+=m[x.first-c]*m[x.first];
		
	}
	cout<<res;
	
	return 0;
}
2023/10/12 17:58
加载中...