Skip to content

Commit

Permalink
15차시 업로드
Browse files Browse the repository at this point in the history
  • Loading branch information
YIM2UL2ET committed Apr 9, 2024
1 parent d536d12 commit 7986fda
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion YIM2UL2ET/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
---
23 changes: 23 additions & 0 deletions YIM2UL2ET/구현/15차시 - BOJ 14719.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>
#include <algorithm>
#include <vector>

int main(void) {
int height, width, res = 0;

std::cin >> height >> width;
std::vector <int> 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;
}

0 comments on commit 7986fda

Please sign in to comment.