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 |
29 | 30 |
Tags
- SOH
- Expanding Polytope Algorithm
- AABB
- c#
- 백준
- 충돌 알고리즘
- Vector
- 내적
- 리눅스
- PS
- C
- 분할축 이론
- ubuntu
- 다이나믹 프로그래밍
- 유니티
- 보로노이다이어그램
- GJK
- 벡터
- 수학
- 외적
- dp
- Doubly Connected Edge List
- 문제풀이
- uclidean algorithm
- 알고리즘
- 우분투
- Graham Scan
- linux
- Unity
- C++
Archives
- Today
- Total
마이 플밍 블로그
백준 14719 - 빗물 본문
https://www.acmicpc.net/problem/14719
14719번: 빗물
첫 번째 줄에는 2차원 세계의 세로 길이 H과 2차원 세계의 가로 길이 W가 주어진다. (1 ≤ H, W ≤ 500) 두 번째 줄에는 블록이 쌓인 높이를 의미하는 0이상 H이하의 정수가 2차원 세계의 맨 왼쪽 위치
www.acmicpc.net
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int H, W;
int Block[510];
int main() {
scanf("%d", &H);
scanf("%d", &W);
for (int i = 0; i < W; i++) {
scanf("%d", &Block[i]);
}
int totalRain = 0;
for (int h = 1; h <= H; h++) {
int wall = -1;
int length = 0;
for (int w = 0; w < W; w++) {
if (Block[w] >= h) {
if(wall != -1)
totalRain += max((w - wall - 1), 0);
wall = w;
}
}
}
printf("%d", totalRain);
return 0;
}
정말 간단한 문제였는데... 삽질해서 푸는데 오래걸렸다.
'문제풀이 > 백준' 카테고리의 다른 글
백준 1806 - 부분 합 (0) | 2022.01.02 |
---|---|
백준 12851 - 숨바꼭질2 (0) | 2021.11.27 |
백준 16953 - A -> B (0) | 2021.10.10 |
백준 2110 - 공유기 설치 (0) | 2021.10.10 |
백준 10816 - 숫자카드2 (0) | 2021.10.10 |