题目链接:http://codeforces.com/contest/1156
B题,构造或者贪心
C题,二分.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n,z;
cin>>n>>z;
ll x[n];
for(int i=0;i<n;i++)
cin>>x[i];
sort(x,x+n);
ll ans=0;
int l=0,r=n/2;
while(l<r){
int mid=(l+r+1)/2;
bool ok=true;
for(int i=0;i<mid;i++)
{
if(x[n-mid+i]-x[i]<z)
ok=false;
}
if(ok)l=mid;
else r=mid-1;
}
cout<<l<<endl;
}
D题,树形DP
E题,数学题