题目链接: http://www.51nod.com/Challenge/Problem.html#!#problemId=1432
排序匹配就行
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#define ll long long
using namespace std;
ll mp[10005];
int main()
{
int n,i;
ll m;
while(cin>>n>>m)
{
for(i=0;i<n;i++)
cin>>mp[i];
sort(mp,mp+n);
int ans=0,flag=0;
for(i=n-1;i>=flag;i--)
{
if(mp[i]+mp[flag]<=m)
flag++;
ans++;
}
cout<<ans<<endl;
}
}