#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define ll long long
#define rep(i,j,k) for(long long i=j;i<=k;i++)
#define per(i,j,k) for(long long i=j;i>=k;i--)
using namespace std;
const int N = 2e5+;
ll h[N];
int main(){
long long n,k;
while(~scanf("%lld%lld",&n,&k)){
memset(h,,sizeof(h));
ll maxx=;
ll x;
ll minn=2e5+;
for (int i=;i<=n;i++){
scanf("%lld",&x);
h[x]++;
minn=min(minn,x);
maxx=max(maxx,x);
}
ll sum=;
per(i,maxx-,minn)
h[i]=h[i+]+h[i];
int cnt=;
// cout<<endl;
// rep(i,minn,maxx){
// printf("%d ",h[i]);
// }
// cout<<endl;
per(i,maxx,minn){
if (h[i]+sum>k){
cnt++;
sum=h[i];
}else{
sum=sum+h[i];
}
}
if (sum>h[minn]){
cnt++;
}
printf("%d\n",cnt);
}
return ;
}

Educational Codeforces Round 52 (Rated for Div. 2) -C的更多相关文章

  1. Educational Codeforces Round 52 (Rated for Div. 2) E. Side Transmutations

    http://codeforces.com/contest/1065/problem/E 数学推导题 #include <bits/stdc++.h> using namespace st ...

  2. Educational Codeforces Round 52 (Rated for Div. 2)

    题目链接 A. Vasya and Chocolate 题意 已知钱,价格,赠送规则求最多获得巧克力数 思路常规算即可 代码 #include <bits/stdc++.h> #defin ...

  3. Educational Codeforces Round 52 (Rated for Div. 2) F. Up and Down the Tree 树型DP

    题面 题意:给你一棵树,你起点在1,1也是根节点,你每次可以选择去你子树的某个叶子节点,也可以选择,从叶子节点返回距离不超过k的一个根, 也就是说,你从1开始,向下跳,选择一个叶子(就是没有子树的节点 ...

  4. Educational Codeforces Round 117 (Rated for Div. 2)

    Educational Codeforces Round 117 (Rated for Div. 2) A. Distance https://codeforces.com/contest/1612/ ...

  5. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  6. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  7. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

  8. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  9. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

随机推荐

  1. springmvc复习笔记----Restful 风格,PathVariable获取 Url实例

    结构 包与之前相同 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=&qu ...

  2. 数据库之mysql篇(5)—— 【转载】mysql练习题

    原帖地址:http://www.cnblogs.com/wupeiqi/articles/5748496.html 范例数据sql: /* Navicat Premium Data Transfer ...

  3. 反射生成 INSERT 多个对象的 SQL 语句(批量插入)

    + View code private static void insertObject(List<?> objectList) throws IllegalAccessException ...

  4. SQL的日期转换

    日期转会计期 SUBSTRING(CONVERT(VARCHAR,getdate(), 20), 1, 7)   2015-06 SUBSTRING(CONVERT(VARCHAR,DATEADD(m ...

  5. sed:-e 表达式 #1,字符 10:未终止的“s”命令

    执行shell脚本时,使用sed变量替换指定的字符串,一直出现这个错误: [root@bqh-118 scripts]# vim while_rz.sh [root@bqh-118 scripts]# ...

  6. TCP/IP协议族(笔记)

    1.HTTP HTTPS DCHP ICMP  SMTP IMAP MIME POP PPTP 协议族 tcp/ip 是基于tcp和ip这两个最初的协议之上的不同的通信协议的大集合 TCP/IP不是一 ...

  7. spring cloud 实践坑点记录

    用spring cloud 微服务框架有一段时间了有一些坑点在这里给大家记录一下希望大家用得着 1.当我们使用聚合性能监控的时候,我们采用 rabbitmq作为消息中间件来收集性能信息最后在使用Tur ...

  8. February 20th, 2018 Week 8th Tuesday

    Receive without conceit, release without struggle. 接受时,不狂妄:放手时,不犹豫. How to understand this quote? Do ...

  9. Spring的AOP开发的相关术语

    转载自 https://www.cnblogs.com/ltfxy/p/9873618.html SpringAOP简介: AOP思想最早是由AOP联盟组织提出的.Spring使用这种思想最好的框架. ...

  10. mysql+centos7+主从复制

    MYSQL(mariadb) MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可.开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的 ...