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 ...
随机推荐
- CSS3实现字体描边
CSS3实现字体描边的两种方法 -webkit-text-stroke: 1px #fff;:不建议,向内描边,字体颜色变细,效果不佳: 用box-shadow模拟描边,向外描边,保留字体粗细,赞! ...
- acre, across
acre The acre is a unit of land area used in the imperial and US customary systems. It is traditiona ...
- 零基础学习java------day17------缓冲字节流,转换字节流,简化流,缓冲字符流,序列化和对象流
1. 缓冲字节流 缓冲区:缓冲区实质上是一个数组.通常它是一个字节数组,但是也可以使用其他种类的数组.但是一个缓冲区不 仅仅 是一个数组.缓冲区提供了对数据的结构化访问,而且还可以跟踪系统的读/写进程 ...
- 手淘lib-flexible布局适配方案
前置知识:什么是rem CSS3新增的一个相对单位rem(root em,根em).rem是相对于根节点(或者是html节点).如果根节点设置了font-size:10px;那么font-size:1 ...
- Android WifiP2p实现
Android WifiP2p实现 Wifi Direct功能早在Android 4.0就以经加入Android系统了,但是一直没有很好的被支持,主要原因是比较耗电而且连接并不是很稳定.但是也有很大的 ...
- Docker学习(四)——Docker容器连接
Docker容器连接 容器中可以运行一些网络应用,要让外部也可以访问这些应用,可以通过-P或-p参数来指定端口映射. 下面我们来实现通过端口连接到一个docker容器. 1.网络端口映射 ...
- oracle(创建数据库对象)
1 --创建数据库 2 --1.SYSDBA系统权限 3 startup:--启动数据库. 4 shutdown:--关闭数据库. 5 alter database[mount]|[open]|[ba ...
- 【Service】【Database】【Cache】Redis
1. 简介: 1.1. redis == REmote DIctionary Server 1.2. KV cache and store, in-memory, 持久化,主从(sentinel实现一 ...
- windows 查看端口被占用,解除占用
查看 (列举端口为2688) netstat -ano | findstr "2688" 解除 原文地址
- 使用缓冲流和byte数组,拷贝文件
package com.itcast.demo05.Buffered;import java.io.*;/** * @author newcityman * @date 2019/7/28 - 17: ...