G - 悲催的移寝

论坛 期权论坛 脚本     
匿名技术用户   2020-12-21 13:33   14   0
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include <algorithm>
#pragma warning(disable:4996)
using namespace std;
int a[100010];
const double pi = 3.1415926;
int main()
{
int t,top=0;
scanf("%d", &t);
while(t--)
{
int n,i,l,num=0,j;
scanf("%d", &n);
scanf("%d", &l);
memset(a,0,sizeof(a));
for (i = 0; i < n; i++)
scanf("%d", &a[i]);
sort(a, a + n);
for(i=0,j=n-1;i<=j;)
{
if (a[i] + a[j] <= l)
{
i++;
j--;
}
else
j--;
num++;
}
if(top) //注意输出数据之间有空行
printf("\n");
printf("%d\n",num);
top++;
}
return 0;
}
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP