优先队列模拟一下就好。

#include<bits/stdc++.h>
using namespace std; priority_queue<int>q; int main()
{
int n;
scanf("%d",&n);
int t; scanf("%d",&t);
for(int i = ; i <= n; i++){
int v; scanf("%d",&v);
q.push(v);
}
int cnt = ;
while(q.top()>=t){
t++; cnt++;
int v = q.top();
q.pop(); q.push(v-);
}
printf("%d\n",cnt);
return ;
}

Codeforces Round #318 (Div. 2) A Bear and Elections (优先队列模拟,水题)的更多相关文章

  1. Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)

    B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  2. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake 水题

    A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Do ...

  3. Codeforces Round #318 (Div. 2) D Bear and Blocks (数学)

    不难发现在一次操作以后,hi=min(hi-1,hi-1,hi+1),迭代这个式子得到k次操作以后hi=min(hi-j-(k-j),hi-k,hi+j-(k-j)),j = 1,2,3... 当k ...

  4. Codeforces Round #318 (Div. 2) B Bear and Three Musketeers (暴力)

    算一下复杂度.发现可以直接暴.对于u枚举a和b,判断一下是否连边,更新答案. #include<bits/stdc++.h> using namespace std; int n,m; ; ...

  5. Codeforces Round #318 (Div. 2) C Bear and Poker (数学)

    简单题,求一下所有数的2和3的幂是任意调整的,把2和3的因子除掉以后必须相等. 求lcm,爆了long long.我得好好反省一下,对连乘不敏感 #include<bits/stdc++.h&g ...

  6. Codeforces Round #385 (Div. 2) A. Hongcow Learns the Cyclic Shift 水题

    A. Hongcow Learns the Cyclic Shift 题目连接: http://codeforces.com/contest/745/problem/A Description Hon ...

  7. Codeforces Round #425 (Div. 2) B. Petya and Exam(字符串模拟 水)

    题目链接:http://codeforces.com/contest/832/problem/B B. Petya and Exam time limit per test 2 seconds mem ...

  8. Codeforces Round #396 (Div. 2) A. Mahmoud and Longest Uncommon Subsequence 水题

    A. Mahmoud and Longest Uncommon Subsequence 题目连接: http://codeforces.com/contest/766/problem/A Descri ...

  9. Codeforces Round #375 (Div. 2) A. The New Year: Meeting Friends 水题

    A. The New Year: Meeting Friends 题目连接: http://codeforces.com/contest/723/problem/A Description There ...

随机推荐

  1. 3.4-3.6 Hive Storage Format

    一.file format ORCFile在HDP 2:更好的压缩,更好的性能: https://zh.hortonworks.com/blog/orcfile-in-hdp-2-better-com ...

  2. 20个Flutter实例视频教程-第02节: 底部导航栏制作-2

    视频地址: https://www.bilibili.com/video/av39709290?p=2 博客地址: https://jspang.com/post/flutterDemo.html#t ...

  3. Eclipse中实现JS代码提示功能

    转发: 用Eclipse写js代码时没有提示,很烦,心累: 找个各种方法以及插件,试了一下,个人感觉AngularJS Eclipse 插件很强,好用,不多说,先装上: 然后重启Eclipse ,右键 ...

  4. 设置android设备时间与pc时间同步的批处理

    新建一个批处理文件 然后输入下面的内容: @echo off echo %date% echo %time% ,%%,%%,%.%,%%,%%,% //通过获取pc时间来设置android设备时间 a ...

  5. 为Docker容器设置静态IP

    此文已由作者袁欢授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 创建docker容器 docker run -it --name=yh -h yh --net=none de ...

  6. android调用其他apk的activity

    <img src="https://img-blog.csdn.net/20160322114625025" alt="" />启动另一个apk的工 ...

  7. bzoj 5120: [2017国家集训队测试]无限之环【最小费用最大流】

    玄妙的建图-- 这种平衡度数的题按套路是先黑白染色然后分别连ST点,相邻格子连黑向白连费用1流量0的边,然后考虑费用怎么表示 把一个点拆成五个,上下左右中,中间点黑白染色连ST, 对于连S的点,中点连 ...

  8. css 的继承性

    目录 css 的继承性是什么? 父元素的属性那些可以被子元素继承,哪些不能呢? css 的继承性是什么? 在面向对象语言都会存在继承的概念,在面向对象语言中,继承的特点:继承了父类的属性和方法. 那么 ...

  9. 【Aizu - ALDS1_7_A】Rooted Trees(树的表达)

    Rooted Trees Descriptions: A graph G = (V, E) is a data structure where V is a finite set of vertice ...

  10. MySQL中group by 与 order by 一起使用排序问题

    假设有一个表:reward(奖励表),表结构如下: CREATE TABLE test.reward ( id ) NOT NULL AUTO_INCREMENT, uid ) NOT NULL CO ...