Codeforces 1166C A Tale of Two Lands

Codeforces 1166C A Tale of Two Lands_第1张图片
枚举x 每次符合条件y的个数 即为对数求和
x i为x位置 i+1为>x
pos-1-(i+1)+1

#include
using namespace std;
#define IO ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define pb emplace_back
#define pii pair
#define all(n) (n).begin(),(n).end()
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define QAQ sort(co+1,co+1+n)
const int maxn = 2e5 + 5;
const ll mod = 998244353;
const int inf = 0x3f3f3f3f;

int a[maxn];
int main()
{
	int n,t;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t;
		a[i]=abs(t);
	}
	sort(a+1,a+n+1);
	ll ans=0;		//全都符合有多少对 2e5*(2e5-1)/2=1e5*2e5=2e10 
	for(int i=1;i<=n;i++)	//x

你可能感兴趣的:(二分)