Codeforces Round #318 (Div. 2) A Bear and Elections (优先队列模拟,水题)
优先队列模拟一下就好。
#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 (优先队列模拟,水题)的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #318 (Div. 2) B Bear and Three Musketeers (暴力)
算一下复杂度.发现可以直接暴.对于u枚举a和b,判断一下是否连边,更新答案. #include<bits/stdc++.h> using namespace std; int n,m; ; ...
- Codeforces Round #318 (Div. 2) C Bear and Poker (数学)
简单题,求一下所有数的2和3的幂是任意调整的,把2和3的因子除掉以后必须相等. 求lcm,爆了long long.我得好好反省一下,对连乘不敏感 #include<bits/stdc++.h&g ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- POJ-3629
Card Stacking Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3927 Accepted: 1541 Des ...
- Asset Catalog Help (十)---Specifying a Resizable Area of an Image
Specifying a Resizable Area of an Image Use the Xcode Slicing feature to specify the dimensions of a ...
- ECharts使用问题
Echarts官网上给的例子,在最后有一个分号. 使用ajax请求,在eval()转化时出现错误,原因就是因为多了一个分号
- python常用第三方库(转载)
Python标准库与第三方库详解(转载) 转载地址: http://www.codeweblog.com/python%e6%a0%87%e5%87%86%e5%ba%93%e4%b8%8e%e7%a ...
- 16.oauth2 + oidc 实现 client部分
把授权和认证过的Server启动一下先 因为代码是之前的代码,所以有些代码需要清除一下 之类注释掉,因为这里暂时没有用到EFCode了 运行的时候发现一点错误 发现登陆的时候使用的RegisterVi ...
- java 关于getProperty()方法中反斜杠问题
问: 在配置文件a.properties中有一行path=C:\test在java中getProperty("path")后,java把\t认为是一个字符TAB.怎样才能取到正确的 ...
- C#backgroundWorker用法
1.在 WinForms 中,有时要执行耗时的操作,在该操作未完成之前操作用户界面,会导致用户界面停止响应.解决的方法就是新开一个线程,把耗时的操作放到线程中执行,这样就可以在用户界面上进行其它操作. ...
- 坑暗花明:又遇 .NET Core 中 System.Data.SqlClient 查询缓慢的问题
之前发布过一篇博文 下单快发货慢:一个 JOIN SQL 引起 SqlClient 读取数据慢的奇特问题,当时遇到的问题是从 SQL Server 2008 R2 中查询获取 100 条记录竟然耗时 ...
- c# IOCP.ClientEx2.ReadWrite 加断点遭遇System.AccessViolationException 问题
起因: 如果在Debug模式下,在IOCP.ClientEx2.ReadWrite.cs while (0 > (nPackSize = _ipcp.Pack(arg_n64PackId, ar ...
- [Xcode 实际操作]八、网络与多线程-(15)使用网址会话对象URLSession下载图片并存储在沙箱目录中
目录:[Swift]Xcode实际操作 本文将演示如何通过网址会话对象URLSession下载图片并存储在沙箱目录中. 网址会话对象URLSession具有在后台上传和下载.暂停和恢复网络操作.丰富的 ...