【题目描述】
【思路】
import java.util.Scanner;
import java.lang.Math;
class Main{
static int n;
static int N = 55;
static int f[] = new int[N]; //记录蚂蚁位置
public static void main(String ags[]){
Scanner reader = new Scanner(System.in);
n = reader.nextInt();
for(int i = 0; i < n; i++)
f[i] = reader.nextInt();
//相遇调头等价于 交换身份继续前进
int left = 0, right = 0; //分别表示左边往右走的蚂蚁数量和右边往左走的蚂蚁数量
for(int i = 1; i < n; i ++)
if( Math.abs( f[i] ) > Math.abs( f[0] ) && f[i] < 0) right ++;
else if( Math.abs( f[i] ) <Math.abs( f[0] ) && f[i] > 0 ) left ++;
//第一只蚂蚁往左走且左边没有往左右走的蚂蚁 or 第一只蚂蚁往右走且右边没有往左走的蚂蚁
if( (f[0] < 0 && left == 0 ) || (f[0] > 0 && right == 0))
System.out.println( 1 );
else
System.out.println( left +right + 1 );
}
}