Description

A military contractor for the Department of Defense has just completed a series of preliminary tests for a new defensive missile called the CATCHER which is capable of intercepting multiple incoming offensive missiles. The CATCHER is supposed to be a remarkable defensive missile. It can move forward, laterally, and downward at very fast speeds, and it can intercept an offensive missile without being damaged. But it does have one major flaw. Although it can be fired to reach any initial elevation, it has no power to move higher than the last missile that it has intercepted.

The tests which the contractor completed were computer simulations of battlefield and hostile attack conditions. Since they were only preliminary, the simulations tested only the CATCHER's vertical movement capability. In each simulation, the CATCHER was fired at a sequence of offensive missiles which were incoming at fixed time intervals. The only information available to the CATCHER for each incoming missile was its height at the point it could be intercepted and where it appeared in the sequence of missiles. Each incoming missile for a test run is represented in the sequence only once.

The result of each test is reported as the sequence of incoming missiles and the total number of those missiles that are intercepted by the CATCHER in that test.

The General Accounting Office wants to be sure that the simulation test results submitted by the military contractor are attainable, given the constraints of the CATCHER. You must write a program that takes input data representing the pattern of incoming missiles for several different tests and outputs the maximum numbers of missiles that the CATCHER can intercept for those tests. For any incoming missile in a test, the CATCHER is able to intercept it if and only if it satisfies one of these two conditions:

The incoming missile is the first missile to be intercepted in this test. 
-or- 
The missile was fired after the last missile that was intercepted and it is not higher than the last missile which was intercepted.

Input

The input data for any test consists of a sequence of one or more non-negative integers, all of which are less than or equal to 32,767, representing the heights of the incoming missiles (the test pattern). The last number in each sequence is -1, which signifies the end of data for that particular test and is not considered to represent a missile height. The end of data for the entire input is the number -1 as the first value in a test; it is not considered to be a separate test.

Output

Output for each test consists of a test number (Test #1, Test #2, etc.) and the maximum number of incoming missiles that the CATCHER could possibly intercept for the test. That maximum number appears after an identifying message. There must be at least one blank line between output for successive data sets.

Note: The number of missiles for any given test is not limited. If your solution is based on an inefficient algorithm, it may not execute in the allotted time.

Sample Input

389
207
155
300
299
170
158
65
-1
23
34
21
-1
-1

Sample Output

Test #1:
maximum possible interceptions: 6 Test #2:
maximum possible interceptions: 2

【题意】求最长下降子序列

#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
const int inf=0x7777777;
const int N=;
int a[N],dp[N];
int get_ans(int n)
{
int ans=;
a[]=inf;
memset(dp,,sizeof(dp));
for(int i=;i<=n;i++)
{
for(int j=i-;j>=;j--)
{
if(a[i]<=a[j])
dp[i]=max(dp[i],dp[j]+);
}
ans=max(ans,dp[i]);
}
return ans;
}
int main()
{
int cas=;
while(scanf("%d",&a[]))
{
if(a[]==-) break;
int cnt=;
while()
{
scanf("%d",&a[cnt]);
if(a[cnt]==-) break;
cnt++;
}
printf("Test #%d:\n",cas++);
printf(" maximum possible interceptions: %d\n\n",get_ans(cnt-));
}
return ;
}

Testing the CATCHER_DP的更多相关文章

  1. A/B Testing的简要知识

    A/B testing主要用来检测网站或者APP的两个版本中哪一个更好,它的中心思想是把流量一分为二,一份用作experiment group,访问新的版本,另一份用作control group,访问 ...

  2. Building the Testing Pipeline

    This essay is a part of my knowledge sharing session slides which are shared for development and qua ...

  3. Monkey Patch/Monkey Testing/Duck Typing/Duck Test

    Monkey Patch Monkey Testing Duck Typing Duck Test

  4. 让产品有效迭代,前端A/B Testing的简单实现

    A/B Testing简介 互联网产品的迭代速度很快,往往一周一小发布,一月一大发布,产品提出的种种需求,哪些改动是提升产品体验的,哪些是阻碍产品进步的,如果没有数据可以参考,仅仅是靠拍脑袋的话,对产 ...

  5. Web Application Penetration Testing Local File Inclusion (LFI) Testing Techniques

    Web Application Penetration Testing Local File Inclusion (LFI) Testing Techniques Jan 04, 2017, Vers ...

  6. Unit Testing with NSubstitute

    These are the contents of my training session about unit testing, and also have some introductions a ...

  7. 模糊测试(fuzz testing)介绍(一)

    模糊测试(fuzz testing)是一类安全性测试的方法.说起安全性测试,大部分人头脑中浮现出的可能是一个标准的“黑客”场景:某个不修边幅.脸色苍白的年轻人,坐在黑暗的房间中,正在熟练地使用各种工具 ...

  8. QA is more than Testing

    前话:在测试这个行业做了挺多年了,都快忘记自己大学的专业是国际经济与贸易,一个选择可能就决定了一生的方向. 但既然做了选择,就走下去. ----------------- 在这么多年的工作中,测试始终 ...

  9. Testing with a mocking framework (EF6 onwards)

    When writing tests for your application it is often desirable to avoid hitting the database.  Entity ...

随机推荐

  1. 错误:Error:未定义标识符"_TCHAR"

    原因:缺少头文件 解决方案:添加一条 #include <tchar.h>

  2. finally块中的代码一定会执行吗?

    在Sun Tutorial中有这样一句话:The finally block always executes when the try block exits. This ensures that t ...

  3. webService—调用webService

    Web service是一个平台独立的,低耦合的,自包含的.基于可编程的web的应用程序,可使用开放的XML(标准通用标记语言下的一个子集)标准来描述.发布.发现.协调和配置这些应用程序,用于开发分布 ...

  4. jQuery Easing动画效果扩展(转)

    jQuery API提供了简单的动画效果如淡入淡出以及自定义动画效果,而今天我给大家分享的是一款jQuery动画效果扩展增强插件jquery.easing.js,使用该插件可以实现直线匀速运功.变加速 ...

  5. Objective-C(一简介)

    Objective-C简介 通常写作ObjC和较少用的Objective C或Obj-C,是扩充C的面向对象编程语言.它主要使用于Mac OS X和GNUstep这两个使用OpenStep标准的系统, ...

  6. OLAP 模型

    OLAP分析的基础是多维数据集,按照其数据存储格式的不同可以分为关系型OLAP(Relational OLAP,ROLAP)和多维型OLAP(Multidimensional OLAP,MOLAP). ...

  7. laypage分页功能demo

    demo代码如下: <div id="view1"></div> <div id="page1"></div> ...

  8. S1:变量

    接触JS一段时间了,但总感觉不得要领,技术得不到提升,翻来覆去,决定对基础知识做一次系统的整理,要坚持每一天都有新的收获 ! 变量,即通过一个名字将一个值关联起来,以后通过变量就可以引用到该值,比如: ...

  9. POJ 1573 Robot Motion 模拟 难度:0

    #define ONLINE_JUDGE #include<cstdio> #include <cstring> #include <algorithm> usin ...

  10. GCJ 2015-Qualification-B Infinite House of Pancakes 枚举,思路,误区 难度:3

    https://code.google.com/codejam/contest/6224486/dashboard#s=p1 题目不难,教训记终生 题目给了我们两种操作:1 所有人都吃一个,简记为消除 ...