题目传送门

 /*
题意:有一堆砖块,每一次操作可以选择消去任意一行,也可以选择消去任意一列。求要消去所有的砖块需要最小的操作数
贪心:首先清楚的是消去最高列的最佳,消去第一行最佳,行列的顺序只对中间过程影响,和结果无关
首先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. Mysql limit offset

    Mysql limit offset 假设数据库表student存在13条数据. 语句1:select * from student limit 9,4 语句2:slect * from studen ...

  2. Unity3D使用小技巧

    原地址:http://unity3d.9tech.cn/news/2014/0411/40178.html 1.Crtl+f摄像机自动适配场景. 2.可以用一个立方体作为底盘. 3.人物角色可以直接引 ...

  3. UINavigation拖动翻页

    #import <UIKit/UIKit.h> #import "ViewController.h" //window窗口 #define WINDOW [[UIApp ...

  4. Lucene4.3开发之分词器总结

    Lucene4.3开发之分词器总结 http://java.chinaitlab.com/tools/940011.html

  5. Minimum Depth of Binary Tree

    二叉树的最小深度 采用递归的方式求左右结点的高度,注意判断一个结点是否是叶子结点(左右子树都不存大). int minDepth(TreeNode *root) { return minDepth(r ...

  6. ZeroMQ(java)之Router/Dealer模式

    本教程转自:http://blog.csdn.net/kobejayandy/article/details/20163527 在开始之前先把guid里面提到的几个ZeroMQ的特性列一下吧: (1) ...

  7. android.os.BadParcelableException: ClassNotFoundException when unmarshalling:解决办法

    例如在用AlarmManager的时候 AlarmManager alarmMgr = (AlarmManager) mContext .getSystemService(Context.ALARM_ ...

  8. 基础知识《五》---Java多线程的常见陷阱

    1.在构造函数中启动线程 我在很多代码中都看到这样的问题,在构造函数中启动一个线程,类似这样: public class A{ public A(){ this.x=1; this.y=2; this ...

  9. tcp ip detatils

    tcp ip detatils 8.关于TCP协议,下面哪种说法是错误的()A.TCP关闭连接过程中,两端的socket都会经过TIME_WAIT状态B.对一个Established状态的TCP连接, ...

  10. discuz插件开发新手入门 超详细

    作为一个新手,目前也是刚刚玩转discuz的插件功能,好东西不敢独享,就拿出来大家一起分享入门的过程.现在网上很多关于discuz的插件教程都是很简单的教程,原因可能是这个东西是商业化的东西,本着分享 ...