题目传送门

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

最新文章

  1. win10下JDK的安装与环境变量配置
  2. Unable to locate secure storage module异常的解决方案
  3. 关于Android中图片大小、内存占用与drawable文件夹关系的研究与分析
  4. Inside Flask - Flask 简介
  5. 【JavsScript】转载---如何成为优秀的前端
  6. java开发之多线程需要学习和理解的东西
  7. apache开源项目 -- tomee
  8. Win10开发必备工具:Visual Studio 2015正式版下载
  9. 关于CSS样式的那些事_导航条菜单讲解
  10. [orleans2.1]这是你没玩过的船新版本
  11. JS获取当月第一天和最后一天
  12. Python设计模式 - UML - 时序图(Sequence Diagram)
  13. Confluence 6 下载和安装 Oracle thin 驱动
  14. eclipse 启动 闪退
  15. Chap3:文件系统中跳转[The Linux Command Line]
  16. HttpSession 和 HttpSession
  17. log4jdbc 与 logback 集合打印日志过多的解决
  18. Oracle:在 debian9 上完美安装 oracle 10.2.0.5 x64
  19. Cache Algorithms
  20. 不以main为入口的函数

热门文章

  1. UITextField竖直居中对齐
  2. RO05 - 如何编写RemObjects SDK服务端 (Delphi Version)
  3. web api 解决跨域的问题
  4. 如何在linux中用命令产生一个范围内的随机数?
  5. [ruby on rails] 跟我学之(4)路由映射
  6. CPU tick counter
  7. cas单点注销失败Error Sending message to url endpoint
  8. JavaScript或jQuery模拟点击超链接和按钮
  9. FastReport for delphi xe 安装步骤
  10. Java for LeetCode 145 Binary Tree Postorder Traversal