题目链接

又是一道完全自己想出来的dp题。

题意:一个w*h的图中,有n个点,给一个s*t的圈,求这个圈能 圈的最多的点

分析:d[i][j]代表i行j列 到第一行第一列的这个方框内有多少个点, 然后枚举圈的右下角的点,

计算在圈的范围的点的方法为

d[i][j]-d[i][j-s]-d[i-t][j]+d[i-t][j-s]。
 #include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;
const int maxn = + ;
int d[][], G[][];
int n, w, h, s, t; int main()
{
int i, j, x, y, sum, ans;
while(~scanf("%d", &n) && n)
{
ans = ;
memset(d, , sizeof(d));
memset(G, , sizeof(G));
scanf("%d%d", &w, &h);
for(i = ; i <= n; i++)
{
scanf("%d%d", &x, &y);
G[y][x] = ;
}
scanf("%d%d", &s, &t);
for(i = ; i <= h; i++)
{
sum = ;
for(j = ; j <= w; j++)
{
if(G[i][j] == )
sum++;
d[i][j] = d[i-][j] + sum;
}
}
for(i = t; i <= h; i++)
for(j = s; j <= w; j++)
{
ans = max(ans, d[i][j]-d[i][j-s]-d[i-t][j]+d[i-t][j-s]);
}
printf("%d\n", ans);
}
return ;
}

poj 2029 Get Many Persimmon Trees (dp)的更多相关文章

  1. (简单) POJ 2029 Get Many Persimmon Trees,暴力。

    Description Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aiz ...

  2. POJ 2029 Get Many Persimmon Trees (二维树状数组)

    Get Many Persimmon Trees Time Limit:1000MS    Memory Limit:30000KB    64bit IO Format:%I64d & %I ...

  3. POJ 2029 Get Many Persimmon Trees

    Get Many Persimmon Trees Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3243 Accepted: 2 ...

  4. poj 2029 Get Many Persimmon Trees 各种解法都有,其实就是瞎搞不算吧是dp

    连接:http://poj.org/problem?id=2029 题意:给你一个map,然后在上面种树,问你h*w的矩形上最多有几棵树~这题直接搜就可以.不能算是DP 用树状数组也可作. #incl ...

  5. POJ 2029 Get Many Persimmon Trees(DP||二维树状数组)

    题目链接 题意 : 给你每个柿子树的位置,给你已知长宽的矩形,让这个矩形包含最多的柿子树.输出数目 思路 :数据不是很大,暴力一下就行,也可以用二维树状数组来做. #include <stdio ...

  6. POJ 2029 Get Many Persimmon Trees(水题)

    题意:在w*h(最大100*100)的棋盘上,有的格子中放有一棵树,有的没有.问s*t的小矩形,最多能含有多少棵树. 解法:最直接的想法,设d[x1][y1][x2][y2]表示选择以(x1, y1) ...

  7. POJ 2029 Get Many Persimmon Trees (模板题)【二维树状数组】

    <题目链接> 题目大意: 给你一个H*W的矩阵,再告诉你有n个坐标有点,问你一个w*h的小矩阵最多能够包括多少个点. 解题分析:二维树状数组模板题. #include <cstdio ...

  8. POJ 2029 Get Many Persimmon Trees 【 二维树状数组 】

    题意:给出一个h*w的矩形,再给出n个坐标,在这n个坐标种树,再给出一个s*t大小的矩形,问在这个s*t的矩形里面最多能够得到多少棵树 二维的树状数组,求最多能够得到的树的时候,因为h,w都不超过50 ...

  9. poj2029 Get Many Persimmon Trees

    http://poj.org/problem?id=2029 单点修改 矩阵查询 二维线段树 #include<cstdio> #include<cstring> #inclu ...

随机推荐

  1. 【BZOJ 1188】 [HNOI2007]分裂游戏

    Description 聪聪和睿睿最近迷上了一款叫做分裂的游戏. 该游戏的规则试: 共有 n 个瓶子, 标号为 0,1,2.....n-1, 第 i 个瓶子中装有 p[i]颗巧克力豆,两个人轮流取豆子 ...

  2. 在eclipse里的 flex 没有可视化的编辑

      注:在4.7版本里去掉了可视化编辑器.   转自:http://3470973.blog.51cto.com/3460973/1135328 最近eclipse切换了一个工作空间,创建的flex项 ...

  3. 送给那些喜欢myeclipse黑色主题但是又不知道怎么配色的人

    设置MyEclipse黑色主题背景 1. 下载 http://eclipsecolorthemes.org/  看哪个合适直接点击进入, 下载右边的epf 2. 下载完成...打开myeclipse. ...

  4. Mongo:将查询结果转换为自定义类

    1.自定义类 public class MyClass { public string Name { get; set; } public int Corners { get; set; } } 2. ...

  5. C++文件操作之 seekg/seekp/tellg/tellp

    问题描述: C++文件操作之 tellg/tellp/seekg/seekp 的使用 问题解决: (1)seekg/tellg/seekp/tellp 使用 tellp用于ostream调用,用来&q ...

  6. 【BZOJ】【3669】【NOI2014】魔法森林

    LCT动态维护MST LCT动态维护MST 我们可以枚举a,然后找从1到n的一条路径使得:这条路径上的b的最大值最小.这个路径肯定在MST上……所以枚举一遍所有的边,动态维护一个关于b值的MST即可. ...

  7. 【锋利的JQuery-学习笔记】输入框提示语-隐藏/显示

    html <div class="search"> <input type="text" id="inputSearch" ...

  8. 跨线程调用控件之MethodInvoker

    原文:http://www.cnblogs.com/cm8448940/archive/2008/07/10/1240045.html 使用到两个控件,一个按钮button1,一个标签label1. ...

  9. Caching Tutorial

    for Web Authors and Webmasters This is an informational document. Although technical in nature, it a ...

  10. Oracle导出空表(从来都没有用过的表)

    Oracle11g默认对空表不分配segment,故使用exp导出Oracle11g数据库时,空表不会导出! .设置deferred_segment_creation参数为FALSE后,无论是空表还是 ...