题目传送门

 /*
题意:有一堆砖块,每一次操作可以选择消去任意一行,也可以选择消去任意一列。求要消去所有的砖块需要最小的操作数
贪心:首先清楚的是消去最高列的最佳,消去第一行最佳,行列的顺序只对中间过程影响,和结果无关
首先sort降序,选择消去列的个数,更新最小值
当时想复杂了,貌似是上学期校赛留下的阴影:)
详细解释:http://blog.csdn.net/liao_jingyi/article/details/40455311
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std; const int MAXN = 1e6 + ;
const int INF = 0x3f3f3f3f;
int a[MAXN]; bool cmp(int x, int y)
{
return x > y;
} int main(void) //Gym 100502E Opening Ceremony
{
//freopen ("E.in", "r", stdin); int n;
while (scanf ("%d", &n) == )
{
for (int i=; i<=n; ++i)
{
scanf ("%d", &a[i]);
} sort (a+, a++n, cmp); int ans = n;
for (int i=; i<=n; ++i)
{
ans = min (ans, i - + a[i]);
} printf ("%d\n", ans);
} return ;
}

贪心 Gym 100502E Opening Ceremony的更多相关文章

  1. CodeForcesGym 100502E Opening Ceremony

    Opening Ceremony Time Limit: 5000ms Memory Limit: 524288KB This problem will be judged on CodeForces ...

  2. Opening Ceremony(贪心)

    Problem E: Opening Ceremony Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 137  Solved: 30[Submit][S ...

  3. 【英语魔法俱乐部——读书笔记】 3 高级句型-简化从句&倒装句(Reduced Clauses、Inverted Sentences) 【完结】

    [英语魔法俱乐部——读书笔记] 3 高级句型-简化从句&倒装句(Reduced Clauses.Inverted Sentences):(3.1)从属从句简化的通则.(3.2)形容词从句简化. ...

  4. 8659 Mine Sweeping

    时间限制:500MS  内存限制:65535K提交次数:37 通过次数:15 题型: 编程题   语言: G++;GCC Description The opening ceremony of the ...

  5. 【托业】【新托业TOEIC新题型真题】学习笔记12-题库八-P7

    155.political figure 政治人物 prominent 160.association n.协会,社团; 联合,联系; 联想; rarely adv.很少地; 罕有地; 极精彩地; 珍 ...

  6. English trip -- VC(情景课)5 D

    Read 阅读 Listen and read. 听并读 Notice from Riverside Library Come and visit Riverside Library.The new ...

  7. AtCoder Beginner Contest 084 C - Special Trains

    Special Trains Problem Statement A railroad running from west to east in Atcoder Kingdom is now comp ...

  8. Codeforces Gym 100803C Shopping 贪心

    Shopping 题目连接: http://codeforces.com/gym/100803/attachments Description Your friend will enjoy shopp ...

  9. Codeforces Gym 100231B Intervals 线段树+二分+贪心

    Intervals 题目连接: http://codeforces.com/gym/100231/attachments Description 给你n个区间,告诉你每个区间内都有ci个数 然后你需要 ...

随机推荐

  1. 1009: josephus问题

    1009: josephus问题 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 549  Solved: 227 Description josephus ...

  2. sqlite 跨数据库查询

    try { $dbh = new PDO($dbrootemp, null, null); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_ ...

  3. ajax页面排序的序号问题

    文章是从我的个人博客上粘贴过来的, 大家也可以访问我的主页 www.iwangzheng.com 目前使用的ajax排序是这样的. 每个table , 都要这样声明 ( table 中必须有2个属性: ...

  4. poj1182(食物链)续

    意 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种. 有人用 ...

  5. Controller之间传递数据:Block传值

    http://itjoy.org/?p=420 前边我们介绍过属性传值和协议传值,这里介绍一下块传值,块类似于C中的函数指针.在Controller中传递数据非常方便,还是继续上一章的例子,将数据从S ...

  6. hadoop(一):深度剖析hdfs原理

    在配置hbase集群将 hdfs 挂接到其它镜像盘时,有不少困惑的地方,结合以前的资料再次学习;  大数据底层技术的三大基石起源于Google在2006年之前的三篇论文GFS.Map-Reduce. ...

  7. 使用clssneme改变图片或样式

    <title>使用className改变样式</title> <style type="text/css"> li{ font-size: 12 ...

  8. Java for LeetCode 064 Minimum Path Sum

    Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...

  9. Heap:Expedition(POJ 2431)

    远征队 题目大意:一部车要从一个地方走到另一个地方,开始的时候车的油箱有P升油,汽车每走1个距离消耗1升油,没有油汽车无法行驶,路上有加油站,可以为汽车加油,设汽车的油缸是无限大小的,问你汽车能否走到 ...

  10. extjs在窗体中添加搜索框

    在extjs中添加搜索框,搜索框代码如下: this.searchField = new Ext.ux.form.SearchField({            store : this.store ...