Codeforces Round #318

居然可以看测试数据,哪里没过一目了然,哈哈哈

 #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 *的更多相关文章

  1. Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2) A. Bear and Elections 优先队列

                                                    A. Bear and Elections                               ...

  2. 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 ...

  3. Codeforces Round #318 (Div. 2) A Bear and Elections (优先队列模拟,水题)

    优先队列模拟一下就好. #include<bits/stdc++.h> using namespace std; priority_queue<int>q; int main( ...

  4. chd校内选拔赛题目+题解

    题目链接   A. Currency System in Geraldion 有1时,所有大于等于1的数都可由1组成.没有1时,最小不幸的数就是1. #include<iostream> ...

  5. Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2)

    以后每做完一场CF,解题报告都写在一起吧   暴力||二分 A - Bear and Elections 题意:有n个候选人,第一个候选人可以贿赂其他人拿到他们的票,问最少要贿赂多少张票第一个人才能赢 ...

  6. 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. ...

  7. Codeforces Round #226 (Div. 2)B. Bear and Strings

    /* 题意就是要找到包含“bear”的子串,计算出个数,需要注意的地方就是不要计算重复. */ 1 #include <stdio.h> #include <string.h> ...

  8. Codeforces 385D - Bear and Floodlight

    385D - Bear and Floodlight 题目大意:有一个人从( l , 0 ) 想走到 ( r , 0 ),有 n 盏路灯,位置为( xi , yi ),每盏路灯都有一个照射的角度ai ...

  9. 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 ...

随机推荐

  1. block,inline和inline-block对比

    总体概念 block和inline这两个概念是简略的说法,完整确切的说应该是 block-level elements (块级元素) 和 inline elements (内联元素).block元素通 ...

  2. 五步搞定Android开发环境部署——非常详细的Android开发环境搭建教程

      在windows安装Android的开发环境不简单也说不上算复杂,本文写给第一次想在自己Windows上建立Android开发环境投入Android浪潮的朋友们,为了确保大家能顺利完成开发环境的搭 ...

  3. strcpy C++实现

    #include <iostream> #include <assert.h> using namespace std; char *strcpy(char *strDest, ...

  4. poj 2378 (dijkstra)

    http://poj.org/problem?id=2387 一个dijkstra的模板题 #include <stdio.h> #include <string.h> #de ...

  5. spinlock原理

    [参考] http://www.searchtb.com/2011/06/spinlock%E5%89%96%E6%9E%90%E4%B8%8E%E6%94%B9%E8%BF%9B.html

  6. ansible操作远程服务器报Error: ansible requires the stdlib json or simplejson module, neither was found!

    通过ansible执行远程命令时报如下异常: Error: ansible requires the stdlib json or simplejson module, neither was fou ...

  7. hdu 5442 (ACM-ICPC2015长春网络赛F题)

    题意:给出一个字符串,长度是2*10^4.将它首尾相接形成环,并在环上找一个起始点顺时针或逆时针走一圈,求字典序最大的走法,如果有多个答案则找起始点最小的,若起始点也相同则选择顺时针. 分析:后缀数组 ...

  8. Unity3d《Shader篇》描边

    Shader "Custom/OutLine" {Properties { _Color ("Main Color", Color) = (.5,.5,.5,1 ...

  9. Selenium FF WebDriver 遍历所有链接(另类爬虫)

    请看这个页面,我想要找到某个公告的内容,必须一个一个打开链接,尼玛好多啊. 于是,我机智的使用selenium打开每一个链接,然后把公告内容写入txt 那需要做一下步奏 1.依次打开一个公告 2.切换 ...

  10. NetBeans常用快捷键

    Ctrl+Space:代码自动完成,在Windows下通常与输入法切换有冲突,我改成了ALT+2: Ctrl+/:注释&取消注释: Alt+Shift+F:编辑器自动格式,由于三个组合键不好按 ...