topcoder SRM 624 DIV2 BuildingHeightsEasy
从大到小遍历一遍,每次取M个元素,然后求得最小的floor即可
int minimum(int M, vector <int> heights)
{
sort(heights.begin(),heights.end());
int minFloor = 10000;
for(int i = heights.size()-1; i >=M-1; -- i){
int floor = 0;
for(int j = 0; j < M; ++j) floor +=heights[i]-heights[i-j];
minFloor =min(minFloor,floor);
}
return minFloor;
}
topcoder SRM 624 DIV2 BuildingHeightsEasy的更多相关文章
- topcoder SRM 624 DIV2 CostOfDancing
排个序,求前k个元素和即可 int minimum(int K, vector <int> danceCost) { sort(danceCost.begin(),danceCost.en ...
- Topcoder Srm 673 Div2 1000 BearPermutations2
\(>Topcoder \space Srm \space 673 \space Div2 \space 1000 \space BearPermutations2<\) 题目大意 : 对 ...
- Topcoder Srm 671 Div2 1000 BearDestroysDiv2
\(>Topcoder \space Srm \space 671 \space Div2 \space 1000 \space BearDestroysDiv2<\) 题目大意 : 有一 ...
- 求拓扑排序的数量,例题 topcoder srm 654 div2 500
周赛时遇到的一道比较有意思的题目: Problem Statement There are N rooms in Maki's new house. The rooms are number ...
- Topcoder srm 632 div2
脑洞太大,简单东西就是想复杂,活该一直DIV2; A:水,基本判断A[I]<=A[I-1],ANS++; B:不知道别人怎么做的,我的是100*N*N;没办法想的太多了,忘记是连续的数列 我们枚 ...
- topcoder SRM 628 DIV2 BracketExpressions
先用dfs搜索所有的情况,然后判断每种情况是不是括号匹配 #include <vector> #include <string> #include <list> # ...
- topcoder SRM 628 DIV2 BishopMove
题目比较简单. 注意看测试用例2,给的提示 Please note that this is the largest possible return value: whenever there is ...
- Topcoder SRM 683 Div2 B
贪心的题,从左向右推过去即可 #include <vector> #include <list> #include <map> #include <set&g ...
- Topcoder SRM 683 Div2 - C
树形Dp的题,根据题意建树. DP[i][0] 表示以i为根节点的树的包含i的时候的所有状态点数的总和 Dp[i][1] 表示包含i结点的状态数目 对于一个子节点v Dp[i][0] = (Dp[v] ...
随机推荐
- 全局压缩http响应头
见代码: public class CompressAttribute : ActionFilterAttribute { public override void OnActionExecuting ...
- sdut 2498【aoe 网上的关键路径】
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2498 代码超时怎么破: #include< ...
- sqlplus使用(一)
一,sqlplus 环境变量 sqlplus的环境变量(来自SQL*Plus® User's Guide and Reference Release 11.2) Parameter or Variab ...
- IBM AppScan 安全扫描:支持弱 SSL 密码套件 分类: 数据安全 2014-06-28 11:34 1844人阅读 评论(0) 收藏
问题描述: 解决方法: 1.Server 2008(R2) 根据appScan的修订建议访问地址:http://msdn.microsoft.com/en-us/library/windows/d ...
- golang debug with LiteIDE
golang 的调试比较麻烦,debug stop into 无法跳转到自己写的代码,但是能够跳转到系统提供的代码. 以下是简单的测试代码: package main import ( "f ...
- hdu 4050 2011北京赛区网络赛K 概率dp ***
题目:给出1-n连续的方格,从0开始,每一个格子有4个状态,左右脚交替,向右跳,而且每一步的步长必须在给定的区间之内.当跳出n个格子或者没有格子可以跳的时候就结束了,求出游戏的期望步数 0:表示不能到 ...
- Cygwin的安装,卸载,以及安装gdb
转载来源 http://10000001.blog.51cto.com/4600383/1341484 1.安装 其实Cygwin的安装时很简单的,需要的安装相应的就可以了,要详细的去网上找,很多 ...
- java大数取模
题目链接:http://lightoj.com/volume_showproblem.php?problem=1214 用java写大数果然是方便多了! import java.math.BigInt ...
- oc中定时器的基本使用
// 时间间隔 调用的对象 调用的方法 用户信息 是否循环 [NSTimer scheduledTimerWithTimeInterval: target:self selector:@select ...
- 枚举PEB获取进程模块列表
枚举进程模块的方法有很多种,常见的有枚举PEB和内存搜索法,今天,先来看看实现起来最简单的枚举PEB实现获取进程模块列表. 首先,惯例是各种繁琐的结构体定义.需要包含 ntifs.h 和 WinDef ...