on
[백준] 14719번:빗물 (Java 자바)
[백준] 14719번:빗물 (Java 자바)
728x90
문제
https://www.acmicpc.net/problem/14719
풀이 및 소스코드
현재 위치에서 양쪽의 max 값 비교 후, 현재 위치의 높이보다 크다면 더해주면 된다.
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; st = new StringTokenizer(br.readLine()); int h = Integer.parseInt(st.nextToken()); // h : 세로 int w = Integer.parseInt(st.nextToken()); // w : 가로 int[] info = new int[w]; st = new StringTokenizer(br.readLine()); for(int i=0;i=0;j--) { left = Math.max(left, info[j]); } // 왼쪽 큰 벽 찾기 for(int j=i+1;j
반응형
from http://jainn.tistory.com/334 by ccl(A) rewrite - 2021-12-01 14:27:33