Testing the CATCHER_DP
Description
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
Output
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的更多相关文章
- A/B Testing的简要知识
A/B testing主要用来检测网站或者APP的两个版本中哪一个更好,它的中心思想是把流量一分为二,一份用作experiment group,访问新的版本,另一份用作control group,访问 ...
- Building the Testing Pipeline
This essay is a part of my knowledge sharing session slides which are shared for development and qua ...
- Monkey Patch/Monkey Testing/Duck Typing/Duck Test
Monkey Patch Monkey Testing Duck Typing Duck Test
- 让产品有效迭代,前端A/B Testing的简单实现
A/B Testing简介 互联网产品的迭代速度很快,往往一周一小发布,一月一大发布,产品提出的种种需求,哪些改动是提升产品体验的,哪些是阻碍产品进步的,如果没有数据可以参考,仅仅是靠拍脑袋的话,对产 ...
- Web Application Penetration Testing Local File Inclusion (LFI) Testing Techniques
Web Application Penetration Testing Local File Inclusion (LFI) Testing Techniques Jan 04, 2017, Vers ...
- Unit Testing with NSubstitute
These are the contents of my training session about unit testing, and also have some introductions a ...
- 模糊测试(fuzz testing)介绍(一)
模糊测试(fuzz testing)是一类安全性测试的方法.说起安全性测试,大部分人头脑中浮现出的可能是一个标准的“黑客”场景:某个不修边幅.脸色苍白的年轻人,坐在黑暗的房间中,正在熟练地使用各种工具 ...
- QA is more than Testing
前话:在测试这个行业做了挺多年了,都快忘记自己大学的专业是国际经济与贸易,一个选择可能就决定了一生的方向. 但既然做了选择,就走下去. ----------------- 在这么多年的工作中,测试始终 ...
- Testing with a mocking framework (EF6 onwards)
When writing tests for your application it is often desirable to avoid hitting the database. Entity ...
随机推荐
- memcached 学习 1—— memcached+spring配置
memcached 学习目录: memcached 学习 1—— memcached+spring配置 这几天自己搭建项目环境,解决问题如下: 有关常见的配置这里没有列出,中间遇到的搭建问题比较顺利g ...
- jQuery_pager.js分页
在做前端项目中,总是需要自己手写类似于这样的分页效果: 这就需要使用jQuery.pager.js文件,其使用方法为:在html中引入三个文件,分别为: <link rel="styl ...
- MySQL 建库、建用户及建表事项
1,MySQL建库语句比较简单,一句话: create database tppamltest3 2,创建用户及授权: insert into mysql.user(Host,User,Passwor ...
- OpenLDAP使用疑惑解答及使用Java完成LDAP身份认证
导读 LDAP(轻量级目录访问协议,Lightweight Directory Access Protocol)是实现提供被称为目录服务的信息服务.目录服务是一种特殊的数据库系统,其专门针对读取,浏览 ...
- autoLyout纯代码适配
前言 1 MagicNumber -> autoresizingMask -> autolayout 以上是纯手写代码所经历的关于页面布局的三个时期 在iphone1-iphone3gs时 ...
- POJ 3522 Slim Span 最小生成树,暴力 难度:0
kruskal思想,排序后暴力枚举从任意边开始能够组成的最小生成树 #include <cstdio> #include <algorithm> using namespace ...
- C# SQLiteDataReader获得数据库指定字段的值
获得数据库指定字段的值,赋给本地变量 (1)如下,获得userinfo数据表里的字段"userid"."orgid", string userid=" ...
- 精通JS 笔记
一,javascript数据类型:undefined,null,boolean,number,string,object 五种加一种复杂类型. 注意大小写,区分大不写函数:functiontypeof ...
- java jdbc----mysql的select、insert、update、delete
//-----------------------------------select---------------------------------- import java.sql.Connec ...
- java基础之 string
一 string public final class String 继承自java.lang.Object类. 实现了接口: java.io.Serializable, Comparable< ...