当前位置:网站首页>2022.8.8 Exam questions for photographer Lao Ma (photographer)
2022.8.8 Exam questions for photographer Lao Ma (photographer)
2022-08-10 03:20:00 【bj_hacker】
题目
2、cameraman old horse(photographer)–800
时间限制: | 空间限制:
题目描述:
有 个人,第 个人身高为 .
Arrange them in two lines,每行 个人.
第二行第 ( )Individuals must be no. than the first row Personal height at least 个单位.
Please determine whether there are eligible programs.
共 组测试数据.
输入格式:
第一行仅有一个正整数 ( ),表示测试数据组数.
接下来有 组测试数据,每组测试数据:
第一行有两个正整数 ( );
第二行有 个正整数 ( ).
输出格式:
对于每组询问,输出一行一个字符串:
If there are eligible programs,输出 ;
否则,输出 ;
The output is case-sensitive.
代码实现
贪心思路
#include<bits/stdc++.h>
using namespace std;
const int maxn=200+10;
int t,n,x;
int h[maxn];
int main(){
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&x);
for(int i=1;i<=2*n;i++)scanf("%d",&h[i]);
sort(h+1,h+2*n+1);
bool flag=true;
for(int i=n+1;i<=2*n;i++) {
if(h[i-n]+x>h[i]){
flag=false;
break;
}
}
if(flag)printf("YES\n");
else printf("NO\n");
}
return 0;
}
边栏推荐
猜你喜欢
随机推荐
微透镜阵列后光传播的研究
MySQL:日志系统介绍 | 错误日志 | 查询日志 | 二进制日志:bin-log数据恢复实践 | 慢日志查询
what is a microcontroller or mcu
翻译软件免费版下载-免费版翻译软件下载
UXDB现在支持函数索引吗?
RESOURCE_EXHAUSTED: etcdserver: mvcc: database space exceeded
牛客刷题——剑指offer(第四期)
将信号与不同开始时间对齐
小菜鸟河北联通上岗培训随笔
In automated testing, test data is separated from scripts and parameterized methods
【Kali安全渗透测试实践教程】第6章 密码攻击
【二叉树-中等】1261. 在受污染的二叉树中查找元素
《GB39732-2020》PDF download
组件的使用
The flask to add and delete
基于C51的中断控制
web开发概述
手把手教你搭建ELK-新手必看-第一章:什么是ELK?
官宣出自己的博客啦
781. 森林中的兔子