社区讨论
第三个点WA求助QAQ
P1102A-B 数对参与者 2已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @lod5g9ff
- 此快照首次捕获于
- 2023/10/31 01:03 2 年前
- 此快照最后确认于
- 2023/11/05 11:28 2 年前
CPP
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
map<long long,int>M;
map<long long, int>::iterator it;
int main()
{
long long N, C;
cin >> N >> C;
for (int i = 0; i < N; i++)
{
long long a;
cin >> a;
M[a]++;
}
int ans = 0;
for (it = M.begin(); it != M.end(); it++)
{
if(M.find(it->first+C)!=M.end())
ans += it->second*M[it->first + C];
}
cout << ans << endl;
return 0;
}
回复
共 1 条回复,欢迎继续交流。
正在加载回复...