Poj Solution 3183

http://poj.org/problem?id=3183

/* @author: */
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
  static final int  MAX=50001;   
 public static void main(String args[]) throws IOException{
  BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
 // Scanner sc = new Scanner (System.in);//�����Ȼ��ʱ
  int h[]=new int[MAX];
  int max=0;
  int result[]=new int[MAX];   
  
    int j=0;  
    int n=Integer.parseInt(buff.readLine()); 
    //int n=sc.nextInt();    
    for(int i=0;i< n;i++)  
      h[i]=Integer.parseInt(buff.readLine()); 
    //  h[i]=sc.nextInt();
    max=h[0];   
    if(h[0]>h[1]) result[j++]=1;//�������еĵ�һ����
    for(int i=1;i< n;i++){//�4δ������е��������
       if(h[i]>=max&&h[i+1]<=h[i]){   
           max=h[i];   
           result[j++]=i+1;//��¼�������������±�.
       }   
       else max=h[i];   
    }   
    for(int m=0;m< j;m++)   
      System.out.printf("%dn",result[m]);   
  }      
}
											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *