这个题其实打眼一看就知道差不多是dp,而且基本确定是前缀和。然后硬钢就行了。。。直接暴力预处理前缀和,然后直接dp就行。

题干:

Description
一种新型的激光炸弹,可以摧毁一个边长为R的正方形内的所有的目标。现在地图上有n(N<=)个目标,用整数Xi,Yi(其值在[,])表示目标在地图上的位置,每个目标都有一个价值。激光炸弹的投放是通过卫星定位的,但其有一个缺点,就是其爆破范围,即那个边长为R的正方形的边必须和x,y轴平行。若目标位于爆破正方形的边上,该目标将不会被摧毁。
Input
输入文件的第一行为正整数n和正整数R,接下来的n行每行有3个正整数,分别表示xi,yi,vi
Output
输出文件仅有一个正整数,表示一颗炸弹最多能炸掉地图上总价值为多少的目标(结果不会超过32767)。
Sample Input Sample Output

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;
#define duke(i,a,n) for(int i = a;i <= n;i++)
#define lv(i,a,n) for(int i = a;i >= n;i--)
#define clean(a) memset(a,0,sizeof(a))
const int INF = << ;
typedef long long ll;
typedef double db;
template <class T>
void read(T &x)
{
char c;
bool op = ;
while(c = getchar(), c < '' || c > '')
if(c == '-') op = ;
x = c - '';
while(c = getchar(), c >= '' && c <= '')
x = x * + c - '';
if(op) x = -x;
}
template <class T>
void write(T x)
{
if(x < ) putchar('-'), x = -x;
if(x >= ) write(x / );
putchar('' + x % );
}
int n,l;
int dp[][];
int main()
{
read(n);read(l);
duke(i,,n)
{
int x,y,v;
read(x);read(y);read(v);
dp[x + ][y + ] = v;
}
duke(i,,)
duke(j,,)
dp[i][j] = dp[i][j - ] + dp[i - ][j] + dp[i][j] - dp[i - ][j - ];
int ans = ;
duke(i,, - l)
{
duke(j,, - l)
ans = max(ans,dp[i + l][j + l] - dp[i + l][j] - dp[i][j + l] + dp[i][j]);
}
printf("%d\n",ans);
return ;
}

最新文章

  1. 《连载 | 物联网框架ServerSuperIO教程》-4.如开发一套设备驱动,同时支持串口和网络通讯。附:将来支持Windows 10 IOT
  2. 常用的JSTL函数
  3. 获取request的变量
  4. [转]Java中的private、protected、public和default的区别
  5. 【转】Eclipse常用快捷键
  6. Gold Balanced Lineup
  7. linux shell--算术运算
  8. 基于visual Studio2013解决C语言竞赛题之1008整除数
  9. linux进程通信之共享内存
  10. 《Create Your own PHP Framework》笔记
  11. RequestMapper
  12. numpy中的meshgrid
  13. Github远程仓库提交代码步骤
  14. python数据结构总结
  15. C#default关键字(泛型代码中的默认关键字)
  16. Android RecycleView 自定义Item的使用
  17. python之路---06 小数据池 编码
  18. 【ASP.NET 问题】IIS发布网站后出现“检测到在集成的托管管道模式下不适用的ASP.NET设置”的解决办法
  19. Android:你要的WebView与 JS 交互方式 都在这里了
  20. 《Linux内核》课本读书笔记 第三章

热门文章

  1. Python语言之数据结构2(字典,引用)
  2. (转)分布式文件存储FastDFS(四)配置fastdfs-apache-module
  3. Python_多线程1(创建线程,简单线程同步)
  4. Apache、Nginx与Tomcat的区别
  5. DOCKER - 容器抓包
  6. ceph对接openstack环境
  7. js 简单小知识
  8. How to start a pdf reader from a Linux command line?
  9. C#关键字详解第一节
  10. python基础 条件和循环