Educational Codeforces Round 52 (Rated for Div. 2) -C
#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的更多相关文章
- 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 ...
- Educational Codeforces Round 52 (Rated for Div. 2)
题目链接 A. Vasya and Chocolate 题意 已知钱,价格,赠送规则求最多获得巧克力数 思路常规算即可 代码 #include <bits/stdc++.h> #defin ...
- Educational Codeforces Round 52 (Rated for Div. 2) F. Up and Down the Tree 树型DP
题面 题意:给你一棵树,你起点在1,1也是根节点,你每次可以选择去你子树的某个叶子节点,也可以选择,从叶子节点返回距离不超过k的一个根, 也就是说,你从1开始,向下跳,选择一个叶子(就是没有子树的节点 ...
- Educational Codeforces Round 117 (Rated for Div. 2)
Educational Codeforces Round 117 (Rated for Div. 2) A. Distance https://codeforces.com/contest/1612/ ...
- 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 ...
- 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 ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- 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 ...
随机推荐
- SQL语句计算距离今天生日还差几天
转载于:http://www.w3dev.cn/article/20110125/sql-compute-birthdate-now-days.aspx SQL语句计算距离生日还差几天原理很简单,将要 ...
- 如何获取Azure AD tenant的tenant Id?
一般情况下,Azure AD用户知道自己tenant域名,因为域名是账户的后缀,例如:contoso.onMicrosoft.com.如果你还不了解什么是Azure AD tenant,可 ...
- 安装window 7系统----计算机经验
上期我们已经成功制作了U盘启动并且也成功进入了PE系统了,在PE微型系统中,除了简单的装系统来恢复C盘,还有什么功能你们可以使用的呢?如果这一期我没有把其他内容讲解的话,千万别乱搞,到时我可能会讲解几 ...
- Dockfile制作镜像
讲一个简单的案例 @哈希码用来校验,这样子会安全 MAINTANIER可能将会被LABEL代替,仅仅说说明一下镜像信息罢了. 1.首先是我们创建一个镜像 [root@ELK-chaofeng08 ~] ...
- 【算法】LeetCode算法题-Count And Say
这是悦乐书的第153次更新,第155篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第12题(顺位题号是38).count-and-say序列是整数序列,前五个术语如下: ...
- Servlet(二):初识Servlet
在手动写完一个Servlet小例子后,是不是有很多疑问,接下来会为大家详细介绍Servlet的知识. 1.什么是Servlet 是在服务器上运行的小程序.一个servlet就是一个Java类,并且可以 ...
- #010 全年级C语言开始统一刷题了,能否坚持下去?
不知道这是咋回事吧,这个系统挺不好使得,出现了一个又一个的问题. 使用过程中做题的那个系统自己就崩了,刷新后那道题得了零分. 前面的几道题难度系数也不小,对于我这个新手来说,但是这个系统太坑了.他明码 ...
- NGINX Load Balancing - HTTP Load Balancer
This chapter describes how to use NGINX and NGINX Plus as a load balancer. Overview Load balancing a ...
- 学习RabbitMQ(三):AMQP事务机制
本文转自:http://m.blog.csdn.net/article/details?id=54315940 在使用RabbitMQ的时候,我们可以通过消息持久化操作来解决因为服务器的异常奔溃导致的 ...
- (转)Spring Boot 2 (六):使用 Docker 部署 Spring Boot 开源软件云收藏
http://www.ityouknow.com/springboot/2018/04/02/docker-favorites.html 云收藏项目已经开源2年多了,作为当初刚开始学习 Spring ...