@font-face{
font-family:"Times New Roman";
}
@font-face{
font-family:"宋体";
}
@font-face{
font-family:"Symbol";
}
@font-face{
font-family:"Wingdings";
}
@font-face{
font-family:"黑体";
}
@list l0:level1{
mso-level-number-format:bullet;
mso-level-suffix:tab;
mso-level-text:\F0B7;
mso-level-tab-stop:36.0000pt;
mso-level-number-position:left;
margin-left:18.0000pt; margin-bottom:0pt; margin-top:0pt; text-indent:0.0000pt;
font-size:12.0000pt; font-family:‘Symbol‘; }
@list l0:level2{
mso-level-number-format:decimal;
mso-level-suffix:tab;
}
@list l0:level3{
mso-level-number-format:decimal;
mso-level-suffix:tab;
}
@list l0:level4{
mso-level-number-format:decimal;
mso-level-suffix:tab;
}
@list l0:level5{
mso-level-number-format:decimal;
mso-level-suffix:tab;
}
@list l0:level6{
mso-level-number-format:decimal;
mso-level-suffix:tab;
}
@list l0:level7{
mso-level-number-format:decimal;
mso-level-suffix:tab;
}
@list l0:level8{
mso-level-number-format:decimal;
mso-level-suffix:tab;
}
@list l0:level9{
mso-level-number-format:decimal;
mso-level-suffix:tab;
}
@list l1:level1{
mso-level-number-format:decimal;
mso-level-suffix:tab;
mso-level-text:"%1.";
mso-level-tab-stop:39.0000pt;
mso-level-number-position:left;
margin-left:39.0000pt; text-indent:-18.0000pt; margin-bottom:0pt; margin-top:0pt; font-family:‘Times New Roman‘; }
@list l2:level1{
mso-level-number-format:bullet;
mso-level-suffix:tab;
mso-level-text:\F06C;
mso-level-tab-stop:81.0000pt;
mso-level-number-position:left;
margin-left:81.0000pt; text-indent:-18.0000pt; margin-bottom:0pt; margin-top:0pt; font-family:‘Wingdings‘; }
@list l3:level1{
mso-level-number-format:decimal;
mso-level-suffix:tab;
mso-level-text:"%1.";
mso-level-tab-stop:18.0000pt;
mso-level-number-position:left;
margin-left:18.0000pt; text-indent:-18.0000pt; margin-bottom:0pt; margin-top:0pt; font-family:‘Times New Roman‘; }
@list l4:level1{
mso-level-number-format:bullet;
mso-level-suffix:tab;
mso-level-text:\F06C;
mso-level-tab-stop:18.0000pt;
mso-level-number-position:left;
margin-left:18.0000pt; text-indent:-18.0000pt; margin-bottom:0pt; margin-top:0pt; font-family:‘Wingdings‘; }
@list l5:level1{
mso-level-number-format:bullet;
mso-level-suffix:tab;
mso-level-text:\F06C;
mso-level-tab-stop:60.0000pt;
mso-level-number-position:left;
margin-left:60.0000pt; text-indent:-18.0000pt; margin-bottom:0pt; margin-top:0pt; font-family:‘Wingdings‘; }
@list l6:level1{
mso-level-number-format:decimal;
mso-level-suffix:tab;
mso-level-text:"%1.";
mso-level-tab-stop:60.0000pt;
mso-level-number-position:left;
margin-left:60.0000pt; text-indent:-18.0000pt; margin-bottom:0pt; margin-top:0pt; font-family:‘Times New Roman‘; }
@list l7:level1{
mso-level-number-format:bullet;
mso-level-suffix:tab;
mso-level-text:\F06C;
mso-level-tab-stop:39.0000pt;
mso-level-number-position:left;
margin-left:39.0000pt; text-indent:-18.0000pt; margin-bottom:0pt; margin-top:0pt; font-family:‘Wingdings‘; }
@list l8:level1{
mso-level-number-format:bullet;
mso-level-suffix:tab;
mso-level-text:\F06C;
mso-level-tab-stop:102.0000pt;
mso-level-number-position:left;
margin-left:102.0000pt; text-indent:-18.0000pt; margin-bottom:0pt; margin-top:0pt; font-family:‘Wingdings‘; }
@list l9:level1{
mso-level-number-format:decimal;
mso-level-suffix:tab;
mso-level-text:"%1.";
mso-level-tab-stop:81.0000pt;
mso-level-number-position:left;
margin-left:81.0000pt; text-indent:-18.0000pt; margin-bottom:0pt; margin-top:0pt; font-family:‘Times New Roman‘; }
@list l10:level1{
mso-level-number-format:decimal;
mso-level-suffix:tab;
mso-level-text:"%1.";
mso-level-tab-stop:102.0000pt;
mso-level-number-position:left;
margin-left:102.0000pt; text-indent:-18.0000pt; margin-bottom:0pt; margin-top:0pt; font-family:‘Times New Roman‘; }
p.p0{
margin:0pt;
margin-bottom:0.0001pt;
margin-bottom:0pt;
margin-top:0pt;
text-align:justify;
font-size:10.5000pt; font-family:‘Times New Roman‘; }
span.10{
font-family:‘Times New Roman‘; }
p.p15{
margin-bottom:0pt;
margin-top:0pt;
border-top:none; ;
mso-border-top-alt:none; ;
border-right:none; ;
mso-border-right-alt:none; ;
border-bottom:none; ;
mso-border-bottom-alt:none; ;
border-left:none; ;
mso-border-left-alt:none; ;
padding:1pt 4pt 1pt 4pt ;
text-align:justify;
font-size:9.0000pt; font-family:‘Times New Roman‘; }
p.p16{
margin-bottom:0pt;
margin-top:0pt;
text-align:left;
font-size:9.0000pt; font-family:‘Times New Roman‘; }
@page{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}@page Section0{
margin-top:72.0000pt;
margin-bottom:72.0000pt;
margin-left:90.0000pt;
margin-right:90.0000pt;
size:595.3000pt 841.9000pt;
layout-grid:15.6000pt;
}
div.Section0{page:Section0;}
NOIP1999 拦截导弹
题目描述 Description
某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统。但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不 能高于前一发的高度。某天,雷达捕捉到敌国的导弹来袭。由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹。
输入描述 Input Description
输入导弹依次飞来的高度(雷达给出的高度数据是不大于30000的正整数)
输出描述 Output Description
输出这套系统最多能拦截多少导弹,如果要拦截所有导弹最少要配备多少套这种导弹拦截系统。
样例输入 Sample Input
389 207 155 300 299 170 158 65
样例输出 Sample Output
6
2
数据范围及提示 Data Size & Hint
导弹的高度<=30000,导弹个数<=20
思路
这道题的突破口在于问题的转化= =
先是第一问: “最多能拦截的导弹数”。根据题目中导弹的毛病,可以把问题转化成经典的最长不上升子序列,动态规划O(cnt2)完美解决;
再看第二问: “最少需要的系统数”。顺延上一问的思路,“不可能由之前已经确定的系统拦截下来的导弹”应当添加到当前位置前的最长上升子序列中。同样是经典问题,动态规划O(cnt2)。
最后稍微得瑟一下→_→在没有优化的情况下,这段代码在发帖前包揽了wikioi上“最快”“最短”以及“内存最少”三项指标~(好吧是因为这题太水了)
1 #include <cstdio>
2 using namespace std;
3 int H[22], Suc[22]={1}, Cnt[22]={1}, mS=0, mC=0;
4 int main()
5 {
6 freopen("testin","r",stdin);
7 freopen("testout","w",stdout);
8 int i,j,t,cnt=0;
9 while(scanf("%d", &t)==1)
10 H[cnt++]=t;
11 for(i=1;i<cnt;++i) {
12 Suc[i]=Cnt[i]=1;
13 for(j=i-1;j>=0;--j) {
14 if(H[j]>=H[i]&&Suc[j]>=Suc[i])
15 Suc[i]=Suc[j]+1;
16 if(H[j]<H[i]&&Cnt[j]>=Cnt[i])
17 Cnt[i]=Cnt[j]+1;
18 }
19 if(Suc[i]>mS)mS=Suc[i];
20 if(Cnt[i]>mC)mC=Cnt[i];
21 }
22 printf("%d\n%d", mS, mC);
23 return 0;
24 }
NOIP1999 拦截导弹