标签:技术分享 static i++ src next import amp rgs logs
代码:
import java.util.Scanner;
public class grand {
public static void main(String[] args) {
int N=new Scanner(System.in).nextInt();
int[] a = new int[N];
int[] b = new int[N];
for (int i = 0; i < a.length; i++) {
a[i] = new Scanner(System.in).nextInt();
}
for (int i = 0; i < a.length; i++) {
int m = 0;
for (int j = 0; j < a.length-1; j++) {
if(a[j+1]<a[j]){
m = j+1;
}
}
a[m] = 101;
b[m]++;
if((m-1)>=0&&b[m-1]!=0){
b[m] = b[m-1]+1;
}
if((m+1)<N&&b[m+1]>b[m]){
b[m] = b[m+1];
}
}
int total = 0;
for (int i = 0; i < b.length; i++) {
total += b[i];
}
System.out.println(total);
}
}
//7,2,3,1,6,5,4,1
//2,1,2,1,4,3,2,1
标签:技术分享 static i++ src next import amp rgs logs
原文地址:http://www.cnblogs.com/-rainbow-/p/7440005.html