76分 #2#3#4TLE

P1102 A-B 数对

你这个复杂度是 $O( n^2 )$的,你用了 map 也过不了
by Razer_System @ 2023-10-25 22:00:58


@[Razer_System](/user/766788) 二分怎么写??? 实在不会
by chenlixin123456 @ 2023-10-27 14:10:30


好吧,正解还是用 map ```cpp #include<bits/stdc++.h> using namespace std; typedef long long ll; ll a[200005]; map<ll,ll> mp; int main(){ ll n,c,count=0; cin>>n>>c; for(int i=1;i<=n;i++){ cin>>a[i]; mp[a[i]]++; } for(int i=1;i<=n;i++){ count+=mp[a[i]-c]; } cout<<count; return 0; } ```
by Razer_System @ 2023-10-27 22:20:12


收 到!!!!!
by chenlixin123456 @ 2023-11-02 20:38:20


|