Problem : 1257 ( 最少拦截系统 ) Judge Status : Accepted
RunId : 2672372 Language : G++ Author : huwenbiao
Code Render Status : Rendered By HDOJ G++ Code Render Version 0.01 Beta
RunId : 2672372 Language : G++ Author : huwenbiao
Code Render Status : Rendered By HDOJ G++ Code Render Version 0.01 Beta
/***************************************************************\
*Author:Hu Wenbiao
*Created Time: Sat 24 Jul 2010 09:45:42 AM CST
*File Name: main.cpp
*Description:贪心方法,每次从前往后能拦截则拦截
\***************************************************************/
//*========================*Head File*========================*\\
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/*----------------------*Global Variable*----------------------*/
int arr[30001],n,sum;
//*=======================*Main Program*=======================*//
using namespace std;
int main(){
//freopen("input","r",stdin);
while(scanf("%d",&n)!=EOF){
for(int i=0;i<n;i++)
scanf("%d",arr+i);
int num=n;
sum=0;
while(num){
int h=30001;
sum++;
for(int p=0;p<n;p++){
if(arr[p]&&arr[p]<=h){
h=arr[p];
arr[p]=0;//拦截过的标记为0
num--;
}
}
}
printf("%d\n",sum);
}
}