hdu 1355 The Peanuts
http://acm.hdu.edu.cn/showproblem.php?pid=1355
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define maxn 10000
using namespace std; struct node
{
int x,y,w;
bool operator <(const node &a)const
{
return w>a.w;
}
}p[maxn];
int n,m,k; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&n,&m,&k);
int cnt=;
for(int i=; i<=n; i++)
{
for(int j=; j<=m; j++)
{
int xx;
scanf("%d",&xx);
if(xx)
{
p[cnt].x=i;
p[cnt].y=j;
p[cnt++].w=xx;
}
}
}
sort(p,p+cnt);
__int64 sum=,ans=;
for(int i=; i<cnt; i++)
{
if(i==)
{
sum+=p[i].x;
}
else sum+=abs(p[i].x-p[i-].x)+abs(p[i].y-p[i-].y);
if(sum+p[i].x+<=k)
{
ans+=p[i].w;
sum++;
}
else break;
}
cout<<ans<<endl;
}
return ;
}
hdu 1355 The Peanuts的更多相关文章
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
随机推荐
- Google谷歌推出goo.gl缩短网址服务 - Blog透视镜
Blog部落格文章的网址,例如本篇文章:http://blog.openyu.org/2014/01/google-goo.gl.html,通常都很冗长,分享到社群网站上,容易使得讯息内容过多,同时也 ...
- (转)C#在父窗口中调用子窗口的过程(无法访问已释放的对象)
C#在父窗口中调用子窗口的过程: 1. 创建子窗口对象 2. 显示子窗口对象 笔者的程序中,主窗体MainFrm通过菜单调用子窗口ChildFrm.在窗体中定义了子窗口对象,然后在菜单项点击事件中 ...
- PowerShell_零基础自学课程_5_自定义PowerShell环境及Powershell中的基本概念
PowerShell_零基础自学课程_5_自定义PowerShell环境及Powershell中的基本概念 据我个人所知,windows下的cmd shell除了能够通过修改系统参数来对其中的环境变量 ...
- 符号化Symbol(符号)体系
http://apps.hi.baidu.com/share/detail/23143648# 符号化Symbol(符号)体系 ArcGIS Engine9.3为开发人员提供了32种符号,主要分为三大 ...
- Best Meeting Point 解答
Question A group of two or more people wants to meet and minimize the total travel distance. You are ...
- poj 2288 Islands and Bridges_状态压缩dp_哈密尔顿回路问题
题目链接 题目描述:哈密尔顿路问题.n个点,每一个点有权值,设哈密尔顿路为 C1C2...Cn,Ci的权值为Vi,一条哈密尔顿路的值分为三部分计算: 1.每一个点的权值之和 2.对于图中的每一条CiC ...
- nyoj 234 吃土豆
描述 Bean-eating * grid. Now you want to eat the beans and collect the qualities, but everyone must ob ...
- Unity SendMessage方法
我们今天研究下SendMessage方法, 如果我们需要执行某一个组件的方法时候可以使用SendMessage gameObject.SendMessage("A"); 即可通知当 ...
- handsontable插件HOOK事件
Hook插件 afterChange (changes: Array, source: String):1个或多个单元格的值被改变后调用 changes:是一个2维数组包含row,prop,o ...
- iOS开发CoreAnimation解读之一——初识CoreAnimation核心动画编程
iOS开发CoreAnimation解读之一——初识CoreAnimation核心动画编程 一.引言 二.初识CoreAnimation 三.锚点对几何属性的影响 四.Layer与View之间的关系 ...