HDU6095 Rikka with Competition 模拟|签到
2017-08-08 21:32
309 查看
题目链接:HDU6095
签个到。
AC代码:
/*
HDU6095
签到成功
AC
*/
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long ll;
const ll maxn=1e5+10;
ll a[maxn];
int main(){
int t;
scanf("%d",&t);
while(t--){
ll n,k;
scanf("%lld%lld",&n,&k);
memset(a,0,sizeof(a));
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
sort(a+1,a+1+n);
ll res=1;
ll am=a
;
for(int i=n-1;i>=1;i--){
if(am-a[i]>k){
continue;
}
else{
am=a[i];
res++;
}
}
printf("%lld\n",res);
}
return 0;
}
签个到。
AC代码:
/*
HDU6095
签到成功
AC
*/
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long ll;
const ll maxn=1e5+10;
ll a[maxn];
int main(){
int t;
scanf("%d",&t);
while(t--){
ll n,k;
scanf("%lld%lld",&n,&k);
memset(a,0,sizeof(a));
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
sort(a+1,a+1+n);
ll res=1;
ll am=a
;
for(int i=n-1;i>=1;i--){
if(am-a[i]>k){
continue;
}
else{
am=a[i];
res++;
}
}
printf("%lld\n",res);
}
return 0;
}
相关文章推荐
- HDU6095 Rikka with Competition(水题,2017 HDU多校联赛 第5场)
- HDU6095 Rikka with Competition
- HDU6095-Rikka with Competition
- hdu6095-思维-Rikka with Competition
- HDU6095-Rikka with Competition
- 2017 Multi-University Training Contest - Team 5:1011&hdu6095、Rikka with Competition
- 【多校联合】(HDU6095)Rikka with Competition
- 【1】【栈模拟】HDU5831 Rikka with Parenthesis II
- 2016 Multi-University Training Contest 8 1011 Rikka with Parenthesis II(模拟)
- HDU 6095 Rikka with Competition【阅读题】【水题】
- 2017 Multi-University Training Contest - Team 5 Rikka with Competition
- hdu_5831_Rikka with Parenthesis II(模拟)
- HDU.5831 Rikka with Parenthesis II【模拟】【8月13】
- HDU 6095 Rikka with Competition
- HDOJ 6095-Rikka with Competition
- hdu 6095-Rikka with Competition
- 【HDU5630】Rikka with Chess(模拟)
- Rikka with Competition hdu 6095
- hdu 6095-Rikka with Competition
- 2017多校5 1011 Rikka with Competition