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 ...
随机推荐
- Effective Java2读书笔记-类和接口(二)
第15条:使可变性最小化 通过一个复数类来看不可变类. public final class Complex { private final double re; private final doub ...
- (转)syslog日志等级
设施.优先级”(facility.priority)设施(facility): kern 0 内核日志消息 user 1 随机的用户日志消息 mail 2 邮件系统日志消息 daemon 3 系统守护 ...
- sgu Ice-cream Tycoon
题意:供应商提供n块价格为c的冰淇淋,一个学生想买n块冰淇淋,手中的钱数总共有t元,为了不让买n块冰淇淋所花费的钱数不超过t元,先尽可能卖给这个学生便宜的冰淇淋. 如果这个学生不能买到所需要的冰淇淋则 ...
- 【转】如何在ubuntu12.04设置adb驱动
原文网址:http://www.xuebuyuan.com/1475698.html 在ubuntu上adb驱动不用像在windows上一样需要额外装,只需要写一个配置文件就可以,下面是设置的步骤: ...
- ucfirst() strtoupper() strtolower()
ucfirst 将字符串第一个字符改大写. 语法: string ucfirst(string str); 返回值: 字符串 函数种类: 资料处理 内容说明 本函数返回字符串 str 第一个字的字 ...
- RTP 协议
转载http://www.cnblogs.com/qingquan/archive/2011/07/28/2120440.html 概述: 实时传送协议(Real-time Transport Pro ...
- 使用Open Flash Chart(OFC)制作图表(Struts2处理)
Java开源项目中制作图表比较出色的就是JFreeChart了,相信大家都听说过,它不仅可以做出非常漂亮的柱状图,饼状图,折线图基本图形之外,还能制作甘特图,仪表盘等图表.在Web应用中可以为项目增色 ...
- java 面向过程实现万年历
public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-gener ...
- DreamWeaver文件保存时,提示"发生共享违例"问题的解决方法
在学习牛腩老师的JS视频中,视频中的例子要求实现一个是23个3相乘的结果,在用Dreamweaver制作时,, <script language="javascript" t ...
- NFinal 视图—用户控件
自定义控件 定义控件 以Label控件为例: 1.首先在Common文件夹下添加Label.cs文件,其中代码如下: //a.control的实体类必须继承NFinal.UserControl类 pu ...