반응형
250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 정렬
- 문자열제곱
- 자료 구조
- 유클리드 호제법
- LeetCode 83 c언어
- 문자열
- 큐
- KMP알고리즘
- 큰 수 연산
- 프로그래머스
- LeetCode 83번
- 다이나믹 프로그래밍
- 해시를 사용한 집합과 맵
- 정수론
- 구현
- 수학
- 조합론
- 별 찍기
- LeetCode Remove Duplicates from Sorted List in c
- Queue
- 브루트포스 알고리즘
- 재귀
- 스택
- 임의 정밀도 / 큰 수 연산
- 사칙연산
- 연결리스트 중복제거
- 실패함수
- 이분 탐색
- 시뮬레이션
- 연결리스트 정렬
Archives
- Today
- Total
hahn
[백준 - JAVA] 성지키기 본문
728x90
반응형
http://boj.kr/7777460aae1e4817a422508869e4ae7d
더보기
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int row = sc.nextInt(),
column = sc.nextInt(),
result = 0, columnCount = 0;
int[] rowPardon = new int[row],
columnPardon = new int[column];
String castleStatus;
for(int i = 0; i < row; i++) {
castleStatus = sc.next();
for(int j = 0; j < castleStatus.length(); j++) {
if(castleStatus.charAt(j) == 'X') {
rowPardon[i]++;
columnPardon[j]++;
}
}
if(rowPardon[i] == 0) result++;
}
for(int i = 0; i < columnPardon.length; i++) {
if(columnPardon[i] == 0) columnCount++;
}
if(columnCount > result) result = columnCount;
System.out.println(result);
}
}
경비원이 없는 행 열을 판별하였고,
둘 중 큰 숫자만큼 경비원이 배치되게 하였음.
더 쉬운 방법이 있을 거 같기도 한데 생각이 나질 않네..
728x90
반응형
'코딩테스트 연습 > 백준(JAVA)' 카테고리의 다른 글
[백준 - JAVA] 이진수 덧셈 (0) | 2021.09.15 |
---|---|
[백준 - JAVA] 부호 (0) | 2021.09.15 |
[백준 - JAVA] 이상한 곱셈 (0) | 2021.09.15 |
[백준 - JAVA] 8진수 2진수 (0) | 2021.09.15 |
[백준 - JAVA] 운동 (0) | 2021.09.14 |