Rikka with Competition hdu 6095
签到题目,排序然后按序清理掉一定会输的结果就可以。
ac代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int a[];
int main()
{
int t;
cin>>t;
while(t--)
{
int n,k;
int sum=;
scanf("%d %d",&n,&k);
for(int i=;i<n;i++) scanf("%d",&a[i]);
sort(a,a+n);
int vis[];
memset(vis,,sizeof(vis));
sum=;
for(int j=n-;j>=;j--)
{
int temp=j-;
if(vis[j]) continue;
while(a[j]-a[temp]>k && temp>=)
{
sum++;
vis[temp]=;
temp--;
}
}
cout<<n-sum<<endl;
}
return ;
}
Rikka with Competition hdu 6095的更多相关文章
- Rikka with Competition
Rikka with Competition 给出一个大小为n的集合\(\{a_i\}\),每次从集合中随机挑出一对数\(a_i,a_j\),如果\(|a_i-a_j|>K\),那么从集合中删掉 ...
- HDU 6095 17多校5 Rikka with Competition(思维简单题)
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...
- hdu 6095 Rikka with Competition---思维题贪心
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6095 题目大意: 任意两个人相比,相差大于K,分低的淘汰,否则两人都有可能赢,剩下的继续比,问有最多 ...
- 2017 beijing icpc E - Rikka with Competition
2017-09-22 22:01:19 writer:pprp As we know, Rikka is poor at math. Yuta is worrying about this situa ...
- Rikka with Subset HDU - 6092 (DP+组合数)
As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some mat ...
- B - Rikka with Graph HDU - 5631 (并查集+思维)
As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some mat ...
- C - Rikka with Badminton --- HDU 6425 快速幂加组合数学
---恢复内容开始--- 题目链接: https://vjudge.net/problem/1812693/origin 这题的mod运算很恶心,真的... 本题有正反两个思路,一个是正面求解其不能成 ...
- 【多校联合】(HDU6095)Rikka with Competition
题意:给定$n$个数,代表$n$个选手的能量高低,现在再给一个$k$,任意在$n$个选手中挑取两个选手比赛,如果$|a_i−a_j|>K$,那么能量高的选手获胜,另一个将被淘汰,否则两个人都有机 ...
- 【2017 Multi-University Training Contest - Team 5】Rikka with Competition
[Link]: [Description] [Solution] 把所有人的能力从大到小排; 能力最大的肯定可能拿冠军; 然后一个一个地往后扫描; 一旦出现a[i-1]-a[i]>k; 则说明从 ...
随机推荐
- Truffle测试框架
Truffle测试框架 2018年06月08日 19:01:19 tianlongtc 阅读数 1000 Truffle 有一个标准的自动化测试框架,让你可以非常方便地测试您的合约.这个框架允许您 ...
- uWSGI Apache 处理 惊群效应的方式 现代的内核
Serializing accept(), AKA Thundering Herd, AKA the Zeeg Problem — uWSGI 2.0 documentationhttps://uws ...
- linux之i2c子系统维护者源码仓库地址
仓库地址: git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git
- <JavaScript> call()、apply()、bind() 的用法
其实是一个很简单的东西,认真看十分钟就从一脸懵B 到完全 理解! 先看明白下面: 例 1 obj.objAge; obj.myFun() // 小张年龄 undefined 例 2 shows() ...
- LC 985. Sum of Even Numbers After Queries
We have an array A of integers, and an array queries of queries. For the i-th query val = queries[i] ...
- Swift 常量
常量一旦设定,在程序运行时就无法改变其值. 常量可以是任何的数据类型如:整型常量,浮点型常量,字符常量或字符串常量.同样也有枚举类型的常量: 常量类似于变量,区别在于常量的值一旦设定就不能改变,而变量 ...
- VBA添加下拉菜单
Sub createMenus() Dim cmdBar As CommandBar Dim cmdMenu As CommandBarPopup Dim cmdBtn As CommandBarBu ...
- MySQL SSL配置(mysql5.7和mysql5.6)
专题一:mysql5.7上开启并配置ssl [root@mysqlmaster01 bin]# ./mysql_ssl_rsa_setup --datadir=/data/mysql_data1/ - ...
- 使用jquery 动态创建form 并提交
$(document).ready(function(){ $("a.delete").click(function(event){ action = this ...
- xdebug调试的原理
转自 https://segmentfault.com/a/1190000002528341 使用PhpStorm+xdebug单步调试程序可以快速帮助自己熟悉项目代码! 运行原理 在实际使用前,我们 ...