Problem Description
怎麼辦呢?多搞幾套系統唄!你說說倒蠻容易,成本呢?成本是個大問題啊.所以俺就到這裏來求救了,請幫助計算一下最少需要多少套攔截系統.
Input
Output
Sample Input
8 389 207 155 300 299 170 158 65
Sample Output
2
Source
</pre><pre name="code" class="cpp">#include <iostream>
#include <string.h>
#include <stdio.h>
#define INF 0x7ffffff
using namespace std;
int main()
{
int n;
while( cin>>n)
{
int i=0,b[10000],c,j,q,k=0;
while(n--)
{
cin>>j;
c=0;
int m=INF;
for(i=0; i<k; i++)
{
if(b[i]>=j&&m>b[i]-j)
{
c=1;
q=i;
m=b[i]-j;
}
}
if(c==0)
{
b[k]=j;
k++;
}
else b[q]=j;
}
cout<<k<<endl;
}
return 0;
}