最少攔截系統
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 44 Accepted Submission(s) : 10
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
怎麼辦呢?多搞幾套系統唄!你說說倒蠻容易,成本呢?成本是個大問題啊.所以俺就到這裏來求救了,請幫助計算一下最少需要多少套攔截系統.
Input
Output
Sample Input
8 389 207 155 300 299 170 158 65
Sample Output
2
Source
#include<stdio.h>
int main()
{
int a[10000],n,i,j,h,flag,flag1,count;
while(scanf("%d",&n)!=EOF)
{
scanf("%d",&a[0]);
count=0;
j=0;
for(i=1;i<=n-1;i++)
{
scanf("%d",&h);
flag=0;
flag1=0;
for(j=0;j<=count&&flag==0;j++)
{
if(h<=a[j])
{
a[j]=h;
flag1=1;
flag=1;
}
}
if(flag1==0)
{
count++;
a[count]=h;
}
}
printf("%d\n",count+1);
}
return 0;
}