HDU 6095 Rikka with Competition
来源:互联网 发布:珠海软件培训机构 编辑:程序博客网 时间:2024/06/06 00:52
题目地址
题意:告诉你n个人的能力值,求出最后的赢家会有哪些。他的获胜条件要不是赢得那方的能力值减去输的那方的能力值,或者随机赢
思路:排序,从大到小去找,知道有一个是一定赢得为止,遍历过的数就是最后的可能的赢家数量
#include <iostream>#include <cstring>#include <string>#include <queue>#include <vector>#include <map>#include <set>#include <stack>#include <cmath>#include <cstdio>#include <algorithm>#define N 100010#define LL __int64#define lson l,mid,ans<<1#define rson mid+1,r,ans<<1|1#define getMid (l+r)>>1#define movel ans<<1#define mover ans<<1|1using namespace std;const LL mod = 1e9 + 7;const double eps = 1e-9;const int inf = 1 << 28;LL num[N];int main() { cin.sync_with_stdio(false); int T; int n, m; cin >> T; while (T--) { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> num[i]; } sort(num, num + n); int ans = 1; for (int i = n - 2; i >= 0; i--) { if (num[i + 1] - num[i] > m) { break; } ans++; } cout << ans << endl; } return 0;}
阅读全文
0 0
- HDU 6095 Rikka with Competition
- HDU 6095 Rikka with Competition
- hdu 6095-Rikka with Competition
- HDU 6095 Rikka with Competition【】
- hdu 6095-Rikka with Competition
- HDU 6095 Rikka with Competition
- 多校5 HDU-6095 Rikka with Competition
- HDU 6095 Rikka with Competition(思维)
- HDU 6095 Rikka with Competition(水~)
- HDOJ 6095-Rikka with Competition
- 刷题——hdu 6095 Rikka with Competition
- 2017多校五 1011题 hdu 6095 Rikka with Competition
- HDU 6095 Rikka with Competition【阅读题】【水题】
- hdu 多校联赛 Rikka with Competition
- Rikka with Competition(HDU 609)
- hdu2639 Rikka with Competition
- HDU6095 Rikka with Competition
- Rikka with Competition
- CSS常考布局的实现方式
- 元素定位(position属性值)有哪些?
- JSP页面超链接中href的值问题
- oracle常用sql语句
- 在职场中怎么样才能让自己闪闪发光?
- HDU 6095 Rikka with Competition
- 使用mysql在mycat中创建表
- [leetcode] 49. Group Anagrams
- 创建线程的两种方式
- Quaternion.Euler
- LeetCode 66 — Plus One( Java 递归)
- SCP 从堡垒机DUMP文件 密码错误解决办法
- python篇4_集合和字典
- Azkban上传文件报错installation Failed.Error chunking