-
Notifications
You must be signed in to change notification settings - Fork 0
/
island.java
53 lines (42 loc) · 1.45 KB
/
island.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.util.Arrays;
import java.util.Scanner;
import java.io.*;
import java.util.*;
public class island {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i = 0; i < n; i++)
{
int islandCount = 0;
int map[] = new int [12];
sc.nextInt();
for(int j = 0; j < 12; j++)
{
map[j] =sc.nextInt();
}
//System.out.print(Arrays.toString(map));
for(int j = 1; j < 11; j++)
{
for(int k = j; k < 11;k++)
{
boolean isIsland = true;
for(int l = j; l <= k; l++)
{
if(map[l] <= map[j-1] || map[l] <= map[k+1])
{
isIsland =false;
}
//System.out.print(isIsland);
}
if(isIsland)
{
islandCount++;
}
//System.out.println();
}
}
System.out.println("" + (i+1) + " " + islandCount);
}
}
}