Racing Car Computer

Input: Standard Input

Output: Standard Output

 

The racing cars of today are equipped with so many sophisticated equipment. Introduction of a new visual transducer which is interfaced with the on-board computer can tell you on the fly how many cars are ahead of you while how many are trailing. There are cars on a racing track. Each has an on-board computer with the new feature. During the race, every single car's computer keeps displaying two integers, (The number of cars in front of him) & (The number of cars behind him) for a particular moment. It is possible that at some time, some of the cars are racing side by side i.e. they are exactly at the same location. A car will not consider any other car at the same location to be a leading or trailing car.

Now, it is suspected that some of the new transducers are not working properly inside such high speed vehicles. The report with all computers' data generated at a particular timestamp is reported to you. You are to determine the minimum number of cars that  have faulty data.

Input

Each test case begins with an integer N (1<=N<=1000), the number of cars on a track. The next N lines each has two integers - b (0<=a,b<=1500) for a particular car.

The last test case is followed by a line with a single 0 indicating the end of input.

Output

For each test case, print a line in the format, “Case X: Y”, where X is the case number & Y is the minimum number of cars that must have faulty data according to the report.

Sample Input                               Output for Sample Input

4

2 2

0 0

0 2

3 1

1

1 1

0

Case 1: 3

Case 2: 1

 #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int ww[][];
int main()
{
int t,n,i,j,x,y,dp[];
t=;
while(scanf("%d",&n),n)
{
memset(ww,,sizeof(ww));
memset(dp,,sizeof(dp));
for(i=; i<n; i++)
{
scanf("%d%d",&x,&y);
if(x+y>=n)continue;
if(ww[x+][n-y]==n-y-x)continue;
ww[x+][n-y]++;
}
for(i=; i<=n; i++)
for(j=; j<i; j++)
dp[i]=max(dp[i],dp[j]+ww[j+][i]);
printf("Case %d: %d\n",t++,n-dp[n]);
}
}

Racing Car Computer dp的更多相关文章

  1. UVA 11766 Racing Car Computer --DP

    题意:电脑记录了某一时刻每个赛车的前面和后面个有多少辆车(多个车并排时在别的车那只算一辆),问最少有多少个不合理的数据. 分析:看到n<=1000时,就尽量往DP上想吧. 每输入一组数据a,b, ...

  2. hdu 2196 Computer(树形DP)

    Computer Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  3. HDU 2136:Computer(树形DP)

    http://acm.split.hdu.edu.cn/showproblem.php?pid=2196 Computer     Description A school bought the fi ...

  4. HDU 2196 树形DP Computer

    题目链接:  HDU 2196 Computer 分析:   先从任意一点开始, 求出它到其它点的最大距离, 然后以该点为中心更新它的邻点, 再用被更新的点去更新邻点......依此递推 ! 代码: ...

  5. SGU 149. Computer Network( 树形dp )

    题目大意:给N个点,求每个点的与其他点距离最大值 很经典的树形dp...很久前就想写来着...看了陈老师的code才会的...mx[x][0], mx[x][1]分别表示x点子树里最长的2个距离, d ...

  6. HDU 2196.Computer 树形dp 树的直径

    Computer Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  7. soj1166. Computer Transformat(dp + 大数相加)

    1166. Computer Transformat Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description A sequenc ...

  8. hdu2196 Computer【树形DP】【换根法】

    Computer Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  9. hdu 2196(Computer 树形dp)

    A school bought the first computer some time ago(so this computer's id is 1). During the recent year ...

随机推荐

  1. 使用idea和studio进行调试的方法

    新入职一个公司,使用得IDE发生了一些变化 ,对于idea的使用,之前有提到过,今天主要的内容是使用idea和studio进行调试的快捷键. 虽然现在计算机开发的语言多种多样,但是使用C#写客户端,使 ...

  2. js,jQuery实现可关闭悬浮框广告特效,兼容(谷歌,火狐,Ie)

    注意不能直接用close()命名关闭广告函数,避免冲突. javascript实现方法: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tr ...

  3. AVAssetWriter 硬编码bug解决

    一.需求 直播助手在录屏过程中,产品要求跟随用户手机屏幕旋转,录屏的视频跟随旋转 二.实施方案 目前触手录,iTools PC端均已经实现该功能,并且该功能只适配iOS9和iOS10系统.猜测实现方案 ...

  4. spring事务详解

    详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt122 Spring事务机制主要包括声明式事务和编程式事务,此处侧重讲解声明式 ...

  5. Nand Flash驱动(实现初始化以及读操作)

    简单制作一个Nand Flash驱动(只需要初始化Flash以及读Flash) 打开2440芯片手册,K9F2G08U0M芯片手册(因为2440中Nand Flash是用的256MB(2Gb)内存,8 ...

  6. YYHS-挑战nbc

    题目描述 Abwad是一名有志向的优秀OI少年.遗憾的是,由于高能宇宙射线的影响,他不幸在NOI中滚粗.不过,Abwad才高一,还有许许多多的机会.在长时间的刻苦学习之后,他实力大增,并企图撼动OI界 ...

  7. tkinter第二章(添加图片,背景图片)

    #插入文件图片import tkinter as tk root = tk.Tk() #创建一个标签类, [justify]:对齐方式textLabel = tk.Label(root,text=&q ...

  8. CCIE-MPLS VPN-实验手册(中卷)

    5:MPLS VPN PE CE OSPF 实验1 5.1 实验拓扑 5.2 实验需求 a. R1 R2 R3 组成P-NETWORK,底层协议采用EIGRP b. R1 R2 R3 直连链路启用LD ...

  9. a链接易混淆与form表单简易验证用法详解

    链接可以说遍布互联网,比如你想提供一个可以跳转到百度首页的链接给网友,那么代码如下: <a href="http://www.baidu.com">百度一下,你就知道& ...

  10. 团队作业4——第一次项目冲刺(Alpha版本)4.27

    一.当天站立式会议照片 本次会议主要内容:组长给大家分配新一步任务,分别汇报目前所完成的内容,完善昨日的解压接口代码,并做测试修正. 二.每个人的工 三.燃尽图 横坐标:工作日,以天为单位,一共七天, ...