当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
随机推荐
[Syntax sugar] About the mapping of category strings to category numeric ids
Algorithm and voice dialogue direction interview question bank
微透镜阵列的高级模拟
FusionCompute产品介绍
LeetCode每日两题02:两数之和 II - 输入有序数组 (均1200道)
mysql -sql编程
【二叉树-中等】508. 出现次数最多的子树元素和
.Net面试经验总结
2022杭电多校联赛第七场 题解
华为HCIE云计算之FC添加ipsan数据存储
首次在我们的centos上安装MySQL
Redis - String|Hash|List|Set|Zset数据类型的基本操作和使用场景
[网鼎杯 2020 青龙组]AreUSerialz
跨站请求伪造(CSRF)攻击是什么?如何防御?
论旅行之收获
别再用 offset 和 limit 分页了,性能太差!
sqlmap dolog外带数据
2022.8.9考试排列变换--1200题解
flask增删改查
web开发概述









