1017 - Brush (III)
Time Limit: 2 second(s) Memory Limit: 32 MB

Samir returned home from the contest and got angry after seeing his room dusty. Who likes to see a dusty room after a brain storming programming contest? After checking a bit he found a brush in his room which has width w. Dusts are defined as 2D points. And since they are scattered everywhere, Samir is a bit confused what to do. He asked Samee and found his idea. So, he attached a rope with the brush such that it can be moved horizontally (in X axis) with the help of the rope but in straight line. He places it anywhere and moves it. For example, the y co-ordinate of the bottom part of the brush is 2 and its width is 3, so the y coordinate of the upper side of the brush will be 5. And if the brush is moved, all dusts whose y co-ordinates are between 2 and 5 (inclusive) will be cleaned. After cleaning all the dusts in that part, Samir places the brush in another place and uses the same procedure. He defined a move as placing the brush in a place and cleaning all the dusts in the horizontal zone of the brush.

You can assume that the rope is sufficiently large. Since Samir is too lazy, he doesn't want to clean all the room. Instead of doing it he thought that he would use at most k moves. Now he wants to find the maximum number of dust units he can clean using at most k moves. Please help him.

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with a blank line. The next line contains three integers N (1 ≤ N ≤ 100), w (1 ≤ w ≤ 10000) and k (1 ≤ k ≤ 100). N means that there are N dust points. Each of the next N lines contains two integers: xi yi denoting the coordinates of the dusts. You can assume that (-109 ≤ xi, yi ≤ 109) and all points are distinct.

Output

For each case print the case number and the maximum number of dusts Samir can clean using at most k moves.

Sample Input

Output for Sample Input

2

3 2 1

0 0

20 2

30 2

3 1 1

0 0

20 2

30 2

Case 1: 3

Case 2: 2


Problem Setter: Jane Alam Jan
题意:给你n个点,然后给你刷子的宽度,然后给你刷的次数k,并且刷子只能够平行与x轴刷,问你刷k次最多能刷多少个点;
思路:肯定与x无关,所以我们按照y从小到大排序,一开始我想用贪心,发现不对,后来发现是个dp;
dp[i][j]表示当前j个点刷了j次最多能刷多少个。
状态转移方程:dp[i][j]=max(dp[i][j-1],dp[i-1][j-cnt[j]]+cnt[j]);
cnt[j]表示当刷这个点时向前能刷到的点,那么当第i次刷时可以选择刷或不刷第j个点,刷为dp[i-1][j-cnt[j]]+cnt[j],不刷为dp[i][j-1];
 1 #include<stdio.h>
2 #include<algorithm>
3 #include<iostream>
4 #include<string.h>
5 #include<stdlib.h>
6 #include<math.h>
7 #include<queue>
8 #include<stack>
9 #include<vector>
10 using namespace std;
11 typedef long long LL;
12 typedef struct pp
13 {
14 int x;
15 int y;
16 } ss;
17 ss ans[200];
18 bool cmp(pp p,pp q)
19 {
20 return p.y<q.y;
21 }
22 int dp[200][10005];
23 vector<int>vec[200];
24 bool flag[300];
25 int ak[300];
26 int main(void)
27 {
28 int i,j,k;
29 scanf("%d",&k);
30 int s;
31 int n,m,v;
32 for(s=1; s<=k; s++)
33 {
34 scanf("%d %d %d",&n,&m,&v);
35 memset(flag,0,sizeof(flag));
36 memset(ak,0,sizeof(ak));
37 for(i=0; i<n; i++)
38 {
39 scanf("%d %d",&ans[i].x,&ans[i].y);
40 }
41 sort(ans,ans+n,cmp);
42 memset(dp,0,sizeof(dp));
43 for(i=0; i<n; i++)
44 {
45 for(j=i; j>=0; j--)
46 {
47 if(ans[i].y-ans[j].y>m)
48 break;
49 ak[i]++;
50 }
51 }
52 int maxx=0;
53 for(j=1; j<=v; j++)
54 {
55 for(i=1; i<=n; i++)
56 {
57 int uu=dp[j-1][i-ak[i-1]]+ak[i-1];
58 dp[j][i]=max(dp[j][i-1],uu);
59 }
60 }
61 printf("Case %d: %d\n",s,dp[v][n]);
62 }
63 return 0;
64 }
 

1017 - Brush (III)的更多相关文章

  1. Lightoj 1017 - Brush (III)

    1017 - Brush (III)    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Sam ...

  2. lightOJ 1017 Brush (III) DP

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1017 搞了一个下午才弄出来,,,,, 还是线性DP做的不够啊 看过数据量就知道 ...

  3. LightOJ 1017 - Brush (III) 记忆化搜索+细节

    http://www.lightoj.com/volume_showproblem.php?problem=1017 题意:给出刷子的宽和最多横扫次数,问被扫除最多的点是多少个. 思路:状态设计DP[ ...

  4. Light OJ 1017 - Brush (III)

    题目大意:     在一个二维平面上有N个点,散落在这个平面上.现在要清理这些点.有一个刷子刷子的宽度是w. 刷子上连着一根绳子,刷子可以水平的移动(在X轴方向上).他可以把刷子放在任何一个地方然后开 ...

  5. Brush (III) LightOJ - 1017

    Brush (III) LightOJ - 1017 题意:有一些点,每刷一次可以将纵坐标在区间(y1,y1+w)范围内的所有点刷光,y1为任何实数.最多能刷k次,求最多共能刷掉几个点. 先将点按照纵 ...

  6. LightOJ1017 Brush (III)(DP)

    题目大概说一个平面上分布n个灰尘,现在要用一个宽w的刷子清理灰尘:选择一个起点,往水平线上扫过去这个水平线上的灰尘就消失了.问最多进行k次这样的操作能清理最多多少灰尘. 没什么的DP. 先按垂直坐标给 ...

  7. lightoj刷题日记

    提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...

  8. dp百题大过关(第一场)

    好吧,这名字真是让我想起了某段被某教科书支配的历史.....各种DP题层出不穷,不过终于做完了orz 虽然各种手糊加乱搞,但还是要总结一下. T1 Monkey Banana Problem    这 ...

  9. 【转】c#、wpf 字符串,color,brush之间的转换

    转自:http://www.cnblogs.com/wj-love/archive/2012/09/14/2685281.html 1,将#3C3C3C 赋给background this.selec ...

随机推荐

  1. Mysql笔记(3)

    查询总数count(1)查询总和sum(数据名) 查询最大值max(数据名) 查询最小值min(数据名) 查询平均值avg(数据名) 去除重复 通过having来过滤group by字句的结果信息 i ...

  2. 学习java的第十天

    一.今日收获 1.java完全学习手册第二章2.9程序流程控制中的选择结构与顺序结构的例题 2.观看哔哩哔哩上的教学视频 二.今日问题 1.例题的问题不大,需要注意大小写,新的语句记忆不牢 2.哔哩哔 ...

  3. Yarn 生产环境核心配置参数

    目录 Yarn 生产环境核心配置参数 ResourceManager NodeManager Container Yarn 生产环境核心配置参数 ResourceManager 配置调度器 yarn. ...

  4. jenkins之代码回滚

    #:通过传参数方式 #:保存后就会看到这样 #;:我们在jenkins服务器写一个脚本 root@ubuntu:~# mkdir /root/script/web1 -pv mkdir: create ...

  5. liunux 6.5设置网卡默认开启

    编辑如下文件; vi /etc/sysconfig/network-scripts/ifcfg-eth0 把 ONBOOT=no 改为 ONBOOT=yes 好了网卡会在启动机器的时候一起启动了.

  6. Mybatis-运行原理

    一.mybatis分层图 二.运行流程 根据全局配置文件创建sqlSessionFactory对象 根据全局配置文件的io流来构建SqlSessionFactoryBuilder对象: 解析(XmlC ...

  7. EM配置问题

    配置EM,首先要保证dbconsole在运行. C:\Users\dingqi>emctl start dbconsoleEnvironment variable ORACLE_UNQNAME ...

  8. Taro 3.5 canary 发布:支持适配 鸿蒙

    一.背景 鸿蒙作为华为自研开发的一款可以实现万物互联的操作系统,一经推出就受到了很大的关注,被国人寄予了厚望.而鸿蒙也没让人失望,今年 Harmony2.0 正式推出供用户进行升级之后,在短短的三个月 ...

  9. 【MySQL】统计累计求和

    https://geek-docs.com/sql/sql-examples/sql-cumulative-sum.html

  10. 度量驱动的DevOps实现

    目录 一.简介 二.度量是什么 三.实践 四.QA问答 一.简介 Wiki上讲:DevOps(Development和Operations的组合词)是一种重视"软件开发人员(Dev)&quo ...