diff --git a/YIM2UL2ET/README.md b/YIM2UL2ET/README.md index 97466af..4ac05c2 100644 --- a/YIM2UL2ET/README.md +++ b/YIM2UL2ET/README.md @@ -16,4 +16,5 @@ | 12차시 | 2024.03.28 | 비트마스킹 | [BOJ 11723](https://www.acmicpc.net/problem/11723) | [BOJ 11723 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/39) | | 13차시 | 2024.04.01 | BFS | [BOJ 7569](https://www.acmicpc.net/problem/7569) | [BOJ 7569 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/42) | | 14차시 | 2024.04.04 | 우선순위 큐 | [BOJ 11286](https://www.acmicpc.net/problem/11286) | [BOJ 11286 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/43) | ---- +| 15차시 | 2024.04.09 | 구현 | [BOJ 14719](https://www.acmicpc.net/problem/14719) | [BOJ 14719 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/48) | +--- \ No newline at end of file diff --git "a/YIM2UL2ET/\352\265\254\355\230\204/15\354\260\250\354\213\234 - BOJ 14719.cpp" "b/YIM2UL2ET/\352\265\254\355\230\204/15\354\260\250\354\213\234 - BOJ 14719.cpp" new file mode 100644 index 0000000..9b6e931 --- /dev/null +++ "b/YIM2UL2ET/\352\265\254\355\230\204/15\354\260\250\354\213\234 - BOJ 14719.cpp" @@ -0,0 +1,23 @@ +#include +#include +#include + +int main(void) { + int height, width, res = 0; + + std::cin >> height >> width; + std::vector vec(width); + for (int i = 0; i < width; i++) std::cin >> vec[i]; + + for (int i = height; i >= 0; i--) { + int cnt = std::count_if(vec.begin(), vec.end(), [&i](int v) -> bool {return v>=i;}); + if (cnt > 1) { + int front = std::find_if(vec.begin(), vec.end(), [&i](int v) -> bool {return v>=i;}) - vec.begin(); + int back = std::find_if(vec.rbegin(), vec.rend(), [&i](int v) -> bool {return v>=i;}) - vec.rbegin(); + res += width - back - front - cnt; + } + } + + std::cout << res; + return 0; +} \ No newline at end of file