codeforce好地方啊 Bear and Elections *
居然可以看测试数据,哪里没过一目了然,哈哈哈
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define MOD 1000000007
const int INF=0x3f3f3f3f;
const double eps=1e-;
typedef long long ll;
#define cl(a) memset(a,0,sizeof(a))
#define ts printf("*****\n");
const int MAXN=;
int n,m,tt;
struct Node
{
int id,x;
void in(int i)
{
scanf("%d",&x);
id=i;
}
friend bool operator<(Node a,Node b)
{
if(a.x==b.x) return a.id<b.id;
else return a.x<b.x;
}
}node[MAXN];
int main()
{
int i,j,k,ca=;
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
while(scanf("%d",&n)!=EOF)
{
priority_queue<Node> q;
for(i=;i<n;i++)
{
node[i].in(i);
q.push(node[i]);
}
int tot=;
while()
{
Node now=q.top();
q.pop();
if(node[].x+tot>now.x||now.id==)
{
break;
}
now.x-=;
tot++;
q.push(now);
}
printf("%d\n",tot);
}
}
codeforce好地方啊 Bear and Elections *的更多相关文章
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2) A. Bear and Elections 优先队列
A. Bear and Elections ...
- codeforces Codeforces Round #318 div2 A. Bear and Elections 【优先队列】
A. Bear and Elections time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces Round #318 (Div. 2) A Bear and Elections (优先队列模拟,水题)
优先队列模拟一下就好. #include<bits/stdc++.h> using namespace std; priority_queue<int>q; int main( ...
- chd校内选拔赛题目+题解
题目链接 A. Currency System in Geraldion 有1时,所有大于等于1的数都可由1组成.没有1时,最小不幸的数就是1. #include<iostream> ...
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2)
以后每做完一场CF,解题报告都写在一起吧 暴力||二分 A - Bear and Elections 题意:有n个候选人,第一个候选人可以贿赂其他人拿到他们的票,问最少要贿赂多少张票第一个人才能赢 ...
- Codeforce 791A - Bear and Big Brother
Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob. ...
- Codeforces Round #226 (Div. 2)B. Bear and Strings
/* 题意就是要找到包含“bear”的子串,计算出个数,需要注意的地方就是不要计算重复. */ 1 #include <stdio.h> #include <string.h> ...
- Codeforces 385D - Bear and Floodlight
385D - Bear and Floodlight 题目大意:有一个人从( l , 0 ) 想走到 ( r , 0 ),有 n 盏路灯,位置为( xi , yi ),每盏路灯都有一个照射的角度ai ...
- Codeforces Round #356 (Div. 1) D. Bear and Chase 暴力
D. Bear and Chase 题目连接: http://codeforces.com/contest/679/problem/D Description Bearland has n citie ...
随机推荐
- Border Tree笔记
最近在学这个东西(当然不是行道树了QAQ..),感觉挺鬼畜的,整个人都不太好了..(特别是鬼畜的sone爷代码与讲稿),感觉他写的并不是普及向算法...?
- Tomcat 7最大并发连接数的正确修改方法
这是个很简单的问题,但是搜了一圈,发现大家都写错了.所以这里总结一下: 几乎所有的中文网页都介绍,要修改Tomcat的默认最大并发连接数,应该进行如下设置(实际上这些步骤是错误的): -------- ...
- 使用Axis2编写webservice客户端,服务端
1.编写客户端 Axis2开发WebService客户端 的3种方式 [参考帖子] http://blog.csdn.net/wangjinwei6912/article/details/851259 ...
- Binary Tree Longest Consecutive Sequence
Given a binary tree, find the length of the longest consecutive sequence path (连续的路径,不是从小到大). The pa ...
- MySQL主从复制数据不一致问题【自增主键】
前言: 今天遇到主从表不一致的情况,很奇怪为什么会出现不一致的情况,因为复制状态一直都是正常的.最后检查出现不一致的数据都是主键,原来是当时初始化数据的时候导致的.现在分析记录下这个问题,避免以后再遇 ...
- Effective C++ -----条款10: 令operator=返回一个reference to *this
比如: Widget& operator=(const Widget& rhs) { ... return* this; } 令赋值(assignment)操作符返回一个referen ...
- Effective C++ -----条款06:若不想使用编译器自动生成的函数,就该明确拒绝
为驳回编译器自动提供的功能,可将相应的成员函数声明为private并且不予实现. 使用像Uncopyable这样的base class也是一种做法(即先声明一个基类,然后私有继承它).这其实有点像使用 ...
- linux 增加用户 useradd 用法小结及配置文件说明
转自CSDN,http://blog.csdn.net/warden2010/article/details/5132290,谢谢作者 在Linux 系统中,所有的用户和组像一个国家.如果国家要繁荣昌 ...
- linux 常用快捷键
切换中英文输入法 Ctrl+space打开终端 Ctrl+Alt+T 终端下复制粘贴 Ctrl + Shift + c/v
- php面向对象加载类、常用设计模式
加载类: include("./Ren.class.php"); include "./Ren.class.php"; 用此方法的时候include后面要加空格 ...