多校5 HDU-6095 Rikka with Competition
2017-08-09 16:01
387 查看
水题
原题链接:
HDU-6095
大意:
摔跤比赛,n 个人的能力为 ai,随机两两举办 n-1 场淘汰赛,当 abs(ai−aj)>K 时,大的那个人获胜,输的人淘汰,否则两个人都有机会获胜(即不产生输赢)。现在问结果有多少种可能性。
思路:一开始被英文题绕死。
考虑最优情况。
代码实现:
原题链接:
HDU-6095
大意:
摔跤比赛,n 个人的能力为 ai,随机两两举办 n-1 场淘汰赛,当 abs(ai−aj)>K 时,大的那个人获胜,输的人淘汰,否则两个人都有机会获胜(即不产生输赢)。现在问结果有多少种可能性。
思路:一开始被英文题绕死。
考虑最优情况。
代码实现:
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define mem(s,t) memset(s,t,sizeof(s)) #define D(v) cout<<#v<<" "<<v<<endl #define inf 0x3f3f3f3f //#define LOCAL inline void read(int &x){ x=0;char p=getchar(); while(!(p<='9'&&p>='0'))p=getchar(); while(p<='9'&&p>='0')x*=10,x+=p-48,p=getchar(); } const int N =1e5+10; int a ; int main() { #ifdef LOCAL freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t; read(t); while(t--){ int n,K; read(n);read(K); for(int i=1;i<=n;i++){ read(a[i]); } sort(a+1,a+n+1); int i; for(i=n;i>1;i--){ if(a[i]-a[i-1]>K){ break; } } printf("%d\n",n-i+1); } return 0; }
相关文章推荐
- HDU 6095 Rikka with Competition【】
- HDU 6095 Rikka with Competition【阅读题】【水题】
- hdu 多校联赛 Rikka with Competition
- HDU 6095 Rikka with Competition(思维)
- HDU 6095 Rikka with Competition(水~)
- HDU 6095 Rikka with Competition
- HDU 6095 17多校5 Rikka with Competition(思维简单题)
- Rikka with Competition hdu 6095
- HDU6095 Rikka with Competition(水题,2017 HDU多校联赛 第5场)
- hdu 6095-Rikka with Competition
- hdu 6095-Rikka with Competition
- HDU 6095 Rikka with Competition
- HDU 6095 Rikka with Competition -2017多校联盟5 第11题
- 【多校训练】hdu 6090 Rikka with Graph
- 【多校联合】(HDU6095)Rikka with Competition
- hdu 多校联赛 6092 Rikka with Subset
- HDU 5828 多校第八场 1008 Rikka with Sequence(线段树--数据加强版)
- Rikka with String HDU - 6086 多校#5 AC自动机DP
- Rikka with Competition(HDU 609)
- (2017多校训练第五场)HDU - 6092 Rikka with Subset 0-1背包