Skip to content

Commit

Permalink
Merge pull request #48 from AlgoLeadMe/15-YIM2UL2ET
Browse files Browse the repository at this point in the history
15-YIM2UL2ET
  • Loading branch information
tgyuuAn authored Jun 27, 2024
2 parents de9a275 + 7986fda commit 31e7195
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 31e7195

Please sign in to comment.