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 |
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)的更多相关文章
- Lightoj 1017 - Brush (III)
1017 - Brush (III) PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Sam ...
- lightOJ 1017 Brush (III) DP
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1017 搞了一个下午才弄出来,,,,, 还是线性DP做的不够啊 看过数据量就知道 ...
- LightOJ 1017 - Brush (III) 记忆化搜索+细节
http://www.lightoj.com/volume_showproblem.php?problem=1017 题意:给出刷子的宽和最多横扫次数,问被扫除最多的点是多少个. 思路:状态设计DP[ ...
- Light OJ 1017 - Brush (III)
题目大意: 在一个二维平面上有N个点,散落在这个平面上.现在要清理这些点.有一个刷子刷子的宽度是w. 刷子上连着一根绳子,刷子可以水平的移动(在X轴方向上).他可以把刷子放在任何一个地方然后开 ...
- Brush (III) LightOJ - 1017
Brush (III) LightOJ - 1017 题意:有一些点,每刷一次可以将纵坐标在区间(y1,y1+w)范围内的所有点刷光,y1为任何实数.最多能刷k次,求最多共能刷掉几个点. 先将点按照纵 ...
- LightOJ1017 Brush (III)(DP)
题目大概说一个平面上分布n个灰尘,现在要用一个宽w的刷子清理灰尘:选择一个起点,往水平线上扫过去这个水平线上的灰尘就消失了.问最多进行k次这样的操作能清理最多多少灰尘. 没什么的DP. 先按垂直坐标给 ...
- lightoj刷题日记
提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...
- dp百题大过关(第一场)
好吧,这名字真是让我想起了某段被某教科书支配的历史.....各种DP题层出不穷,不过终于做完了orz 虽然各种手糊加乱搞,但还是要总结一下. T1 Monkey Banana Problem 这 ...
- 【转】c#、wpf 字符串,color,brush之间的转换
转自:http://www.cnblogs.com/wj-love/archive/2012/09/14/2685281.html 1,将#3C3C3C 赋给background this.selec ...
随机推荐
- 【翻译】.NET 6 中的 dotnet monitor
原文:Announcing dotnet monitor in .NET 6 我们在 2020 年 6 月首次推出了dotnet monitor 作为实验工具,并在去年(2020年)努力将其转变为生产 ...
- HDFS04 HDFS的读写流程
HDFS的读写流程(面试重点) 目录 HDFS的读写流程(面试重点) HDFS写数据流程 网络拓扑-节点距离计算 机架感知(副本存储节点的选择) HDFS的读数据流程 HDFS写数据流程 客服端把D: ...
- acclaim
欲学acclaim,先学claim.即使学会claim,未必记住acclaim. [LDOCE] claim的词源是cry out, shoutverb:1. state that sth is tr ...
- virtualBox 系统移植
把virtualbox已经存在的系统移植到其他机器. 1.把系统如下文件考到一个安装了virtualbox的机器. 2.点击控制-->注册 然后浏览到复制的文件路径. 3.修改uuid 不管是l ...
- java职业路线图
- Properties类继承HashTable类,一般用来给程序配置属性文件。
package com.itcast.demo04.Prop;import jdk.internal.util.xml.impl.ReaderUTF8;import sun.nio.cs.UTF_32 ...
- 【Python】matplotlib直方图纵轴显示百分比
其实很简单,就是算了一下百分比权重,乘以了一个权重值 import matplotlib.pyplot as plt from matplotlib.ticker import FuncFormatt ...
- springboot项目启动慢,怀疑jdk有问题
项目启动慢,并且没有启动日志,开发环境和windows服务器都正常,到linux后出现问题,你觉得会是哪儿的问题? 最近收到一位同事求助,说springboot应用在客户的一台Linux机器上启动非常 ...
- 【简】题解 AWSL090429 【原子】
预处理出每个原子最近的不能合并的位置 枚举当前位置和前面断开的位置合并 发现还是不能过 考虑用选段树优化 但是因为每次转移的最优点是在前面可以合并的范围内 dp值加上当前的到该点的最大值 因为每个位置 ...
- 『学了就忘』Linux服务管理 — 75、Linux系统中的服务
目录 1.服务的介绍 2.Windows系统中的服务 3.Linux系统中服务的分类 4.独立的服务和基于xinetd服务的区别 5.如何查看一个服务是独立的服务还是基于xinetd的服务 (1)查看 ...