贪心 Gym 100502E Opening Ceremony
/*
题意:有一堆砖块,每一次操作可以选择消去任意一行,也可以选择消去任意一列。求要消去所有的砖块需要最小的操作数
贪心:首先清楚的是消去最高列的最佳,消去第一行最佳,行列的顺序只对中间过程影响,和结果无关
首先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的更多相关文章
- CodeForcesGym 100502E Opening Ceremony
Opening Ceremony Time Limit: 5000ms Memory Limit: 524288KB This problem will be judged on CodeForces ...
- Opening Ceremony(贪心)
Problem E: Opening Ceremony Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 137 Solved: 30[Submit][S ...
- 【英语魔法俱乐部——读书笔记】 3 高级句型-简化从句&倒装句(Reduced Clauses、Inverted Sentences) 【完结】
[英语魔法俱乐部——读书笔记] 3 高级句型-简化从句&倒装句(Reduced Clauses.Inverted Sentences):(3.1)从属从句简化的通则.(3.2)形容词从句简化. ...
- 8659 Mine Sweeping
时间限制:500MS 内存限制:65535K提交次数:37 通过次数:15 题型: 编程题 语言: G++;GCC Description The opening ceremony of the ...
- 【托业】【新托业TOEIC新题型真题】学习笔记12-题库八-P7
155.political figure 政治人物 prominent 160.association n.协会,社团; 联合,联系; 联想; rarely adv.很少地; 罕有地; 极精彩地; 珍 ...
- English trip -- VC(情景课)5 D
Read 阅读 Listen and read. 听并读 Notice from Riverside Library Come and visit Riverside Library.The new ...
- AtCoder Beginner Contest 084 C - Special Trains
Special Trains Problem Statement A railroad running from west to east in Atcoder Kingdom is now comp ...
- Codeforces Gym 100803C Shopping 贪心
Shopping 题目连接: http://codeforces.com/gym/100803/attachments Description Your friend will enjoy shopp ...
- Codeforces Gym 100231B Intervals 线段树+二分+贪心
Intervals 题目连接: http://codeforces.com/gym/100231/attachments Description 给你n个区间,告诉你每个区间内都有ci个数 然后你需要 ...
随机推荐
- hdu.5203.Rikka with wood sticks(数学推导:一条长度为L的线段经分割后可以构成几种三角形)
Rikka with wood sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/O ...
- 悦动达人 (多维dp)
悦动达人 Description 一个游戏,在屏幕上有5个格子形成一行,每一秒都会有一个格子闪烁,格子闪烁时你需要保证至少有一只手指在格子上面, 现在我们已经知道第i秒时,第xi个格子会闪烁,我们假设 ...
- 用LoadRunner实现接口测试
接口测试的两种方法 其实无论用那种测试方法,接口测试的原理是通过测试程序模拟客户端向服务器发送请求报文,服务器接收请求报文后对相应的报文做出处理然后再把应答报文发送给客户端,客户端接收应答报文这一个过 ...
- MFC 中控件的启用与禁用
启用和禁用控件可以调用CWnd::EnableWindow 函数. BOOL EnableWindow(BOOL bEnable = TRUE); 判断控件是否可用可以调用 CWnd::IsWindo ...
- shell编程报错 [: missing `]'
NGINX_RATES=50 NGINX_BURST=3000 NGINX_PATH=/opt/srv/nginx/conf/nginx.conf BEE_PATH=/opt/srv/nginx/co ...
- POJ 2492 并查集扩展(判断同性恋问题)
G - A Bug's Life Time Limit:10000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u S ...
- HDOJ 2097
#include<stdio.h> int func(int n,int k) { ; a=n; ) { b+=a%k; a=a/k; } return b; } int main() { ...
- sharepoint读取启用了追加功能的多行文本的历史版本记录
当建立多行文本栏时,有个功能就是"追加对现有文本所做的更改",这个功能启用后,这个多行文本就只运行追加内容而不允许修改以前提交的内容.常常被应用在多个用户之间的协作.问题的追踪等记 ...
- 使用wkhtmltopdf实现HTML转PDF的解决方案
最近,项目需要将HTML页面转换为PDF文件,所以就研究了下HTML转PDF的解决方案,发现网上比较流行的解决方案有3种: (1)iText (2)Flying Saucer (3)wkhtmltop ...
- 修改PHP网站默认首页
一般默认的首页文件是index.php index.php3 index.html index.htm之类的,要想修改为myNewIndex.php, 进入服务器Apache目录,找到httpd.co ...