๋ฐ์ํ
๋ฌธ์ ํ์ด
import java.util.*;
import java.io.FileInputStream;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int widthMax = 1000;
int heightMax = 255;
int test_count = 10;
for(int test_case = 1; test_case <= test_count; test_case++)
{
int buildingCount = sc.nextInt();
int[][] map = new int[widthMax][heightMax];
// ๋น๋ฉ ์ ๋ณด ์
๋ ฅ
for(int width=0; width<buildingCount; width++){
int heightLimit = sc.nextInt();
for(int height=0; height<heightLimit; height++){
map[width][height] = 1;
}
}
//1๋ฒ์งธ ๋น๋ฉ 1์ธต๋ถํฐ ์ผ์ชฝ ์ค๋ฅธ์ชฝ ํ์ธ
int count = 0;
for(int width=(0+2); width<(widthMax-2); width++){ //๋งจ ์ผ์ชฝ ์ค๋ฅธ์ชฝ ๋์นธ์ ๊ฑด๋ฌผ ์ง์ด์ง์ง ์์
for(int height=0; height<heightMax; height++){
boolean left = (map[width-1][height] == 0) && (map[width-2][height] == 0);
boolean right = (map[width+1][height] == 0) && (map[width+2][height] == 0);
if(map[width][height] == 1 && left && right ){
count++;
}
}
}
//System.out.println(Arrays.deepToString(map));
System.out.println("#" + test_case + " " + count);
}
}
}
๋ฐ์ํ
'๐ฏ Coding Test' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค] 9012 ๊ดํธ (0) | 2022.02.11 |
---|---|
[๋ฐฑ์ค] 10828 ์คํ (๋ฐฐ์ด, LinkedList๋ก ๊ตฌํํด๋ณด๊ธฐ) (0) | 2022.02.10 |
SWEA 1204. [S/W ๋ฌธ์ ํด๊ฒฐ ๊ธฐ๋ณธ] 1์ผ์ฐจ - ์ต๋น์ ๊ตฌํ๊ธฐ (0) | 2022.02.10 |
๋ฐฑ์ค 1026๋ฒ : ๋ณด๋ฌผ (0) | 2021.10.27 |
๋ฐฑ์ค 1946๋ฒ : ์ ์ ์ฌ์ (0) | 2021.10.26 |