当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
随机推荐
算法与语音对话方向面试题库
官宣出自己的博客啦
gbase 8a数据库如何查看数据或数据文件是否正常?
【web渗透】SSRF漏洞超详细讲解
2022.8.8考试从记忆中写入(memory)题解
ECCV 2022 Oral | CCPL: 一种通用的关联性保留损失函数实现通用风格迁移
元素的盒子模型+标签的尺寸大小和偏移量+获取页面滚动距离
SQL注入的order by ,limit与宽字节注入
2022.8.9考试排列变换--1200题解
2022 Top Net Cup Quals Reverse Partial writeup
Deep Learning (5) CNN Convolutional Neural Network
【干货】集成学习原理总结
Database management tool: dynamic read-write separation
16. 最接近的三数之和
官宣出自己的博客啦
sqlmap dolog外带数据
c# 解决CS8602告警 解引用可能出现空引用
UXDB现在支持函数索引吗?
ImportError: Unable to import required dependencies: numpy
深度学习(五) CNN卷积神经网络