Racing Car Computer dp
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 N 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, a (The number of cars in front of him) & b (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 - a & 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的更多相关文章
- UVA 11766 Racing Car Computer --DP
题意:电脑记录了某一时刻每个赛车的前面和后面个有多少辆车(多个车并排时在别的车那只算一辆),问最少有多少个不合理的数据. 分析:看到n<=1000时,就尽量往DP上想吧. 每输入一组数据a,b, ...
- hdu 2196 Computer(树形DP)
Computer Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- HDU 2136:Computer(树形DP)
http://acm.split.hdu.edu.cn/showproblem.php?pid=2196 Computer Description A school bought the fi ...
- HDU 2196 树形DP Computer
题目链接: HDU 2196 Computer 分析: 先从任意一点开始, 求出它到其它点的最大距离, 然后以该点为中心更新它的邻点, 再用被更新的点去更新邻点......依此递推 ! 代码: ...
- SGU 149. Computer Network( 树形dp )
题目大意:给N个点,求每个点的与其他点距离最大值 很经典的树形dp...很久前就想写来着...看了陈老师的code才会的...mx[x][0], mx[x][1]分别表示x点子树里最长的2个距离, d ...
- HDU 2196.Computer 树形dp 树的直径
Computer Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- soj1166. Computer Transformat(dp + 大数相加)
1166. Computer Transformat Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description A sequenc ...
- hdu2196 Computer【树形DP】【换根法】
Computer Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- hdu 2196(Computer 树形dp)
A school bought the first computer some time ago(so this computer's id is 1). During the recent year ...
随机推荐
- [2017-05-31]Abp介绍和经验分享-目录
很久没动博客了,人比较懒. 最近想写点啥,主要就介绍下ABP框架和我这两年的使用经验. 文档翻译之类的工作就算了,需要的请参考: 官方文档 PS:官方文档末尾有中文文档的链接,这里就不贴了 先列个提纲 ...
- js中数组对象根据内容查找符合的第一个对象
今天在写一个混合开发版的app,其中一个功能是扫描快递单号,客户要求不能扫描重复的快递单号!所有就验证查出. 首先实现思路就是: 1.定义一个全局数组变量:var nubList = []; 2.进入 ...
- oracle语句批处理
数据量有40万条,从一个对象table_01一条一条取数到对象table_02,如果用原始的 Statement Statmt =comm.createStatement(); String sql= ...
- URI和URL的区别 一起学习呗
一直存在很多技术上的争论,其中最为妙的恐怕就是web地址应该叫什么的问题.通常情况就是这样:有人把地址栏的内容叫"URL",这时候有些人就来劲了:"不!其实那就是URI. ...
- selenium 对https网站(加密证书)进行自动化测试
由于公司需要,被测网站有证书加密,由于在selenium启动firefox的时候,它会重新建一个profile作为启动的profile,所以无论你怎么把站点设为可信任站点,在selenium启动的fi ...
- 工具类:关于解决数据库中的日期格式,经过response.getWriter().write(json)打到前台日期格式混乱的问题的总结
经过response.getWriter().write(json)打到前台日期格式混乱的问题的总结 import java.text.SimpleDateFormat;import net.sf.j ...
- 向GitHub 提交你的源代码
之前的这篇文章「Git入门篇」相信大家都已经对 Git 的基本操作熟悉了,但是这篇文章只介绍了对本地 Git 仓库的基本操作,今天我就来介绍下如何跟远程仓库一起协作,教你们向 GitHub 上提交你们 ...
- 猜数字游戏--基于python
"""题目:练习使用python写一个猜数字的游戏,数字范围0-100,每次猜错,需要给出缩小后的范围,每个人只有10次的猜测机会,猜测机会用完游戏结束!"&q ...
- WebApi Ajax 跨域请求解决方法(CORS实现)(作者:jianxuanbing)
概述 ASP.NET Web API 的好用使用过的都知道,没有复杂的配置文件,一个简单的ApiController加上需要的Action就能工作.但是在使用API的时候总会遇到跨域请求的问题,特别各 ...
- Web in Linux小笔记001
Linux灾难恢复: Root密码修复 Centos single Filesystem是硬盘文件根目录,无法再cd ..就像macitosh 硬盘图标 Pwd:显示绝对路径 MBR修复 模拟MBR被 ...