package com.company;
import java.util.Scanner;
public class Main {
public static boolean canSee1(int[] a, int x, int y) {
int len = a.length;
boolean ret = true;
for (int i = x + 1; i < y; i++) {
if (a[i] > a[x] || a[i] > a[y]) {
ret = false;
break;
}
}
return ret;
}
public static boolean canSee2(int[] a, int x, int y) {
int len = a.length;
boolean ret = true;
for (int i = y + 1; i < len ; i++) {
if (a[i] > a[x] || a[i] > a[y]) {
ret = false;
break;
}
}
for (int i = 0; i < x; i++) {
if (a[i] > a[x] || a[i] > a[y]) {
ret = false;
break;
}
}
return ret;
}
public static void main(String[] args) {
// write your code here
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextInt()) {
int n = scanner.nextInt();
int[] h = new int[n];
int count = 0;
for (int i = 0; i < n; i++) {
h[i] = scanner.nextInt();
}
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (canSee1(h, i, j) || canSee2(h, i, j)) {
count++;
}
}
}
System.out.println(count);
}
}
}
我特么以为9点10分交卷,没有提交上代码。。。。。真是头号大**。。。。。。大家帮我Review一下代码呗