문제 링크입니다: https://www.acmicpc.net/problem/25527
25527번: Counting Peaks of Infection
For the new infectious disease, COVID-99, numbers of new positive cases of PCR tests conducted in the city are reported daily. You are requested by the municipal public relations department to write a program that counts the number of the peaks so far of t
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
while (true) | |
{ | |
int N; | |
cin >> N; | |
if (N == 0) | |
{ | |
break; | |
} | |
vector<int> v(N); | |
for (int i = 0; i < N; i++) | |
{ | |
cin >> v[i]; | |
} | |
int cnt = 0; | |
for (int i = 1; i < N - 1; i++) | |
{ | |
if (v[i] > v[i - 1] && v[i] > v[i + 1]) | |
{ | |
cnt++; | |
} | |
} | |
cout << cnt << "\n"; | |
} | |
return 0; | |
} |

개발환경:Visual Studio 2022
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 25516번 거리가 K이하인 트리 노드에서 사과 수확하기 (0) | 2022.09.04 |
---|---|
백준 25513번 빠른 오름차순 숫자 탐색 (0) | 2022.09.04 |
백준 25501번 재귀의 귀재 (0) | 2022.08.28 |
백준 15235번 Olympiad Pizza (0) | 2022.08.04 |
백준 9517번 아이 러브 크로아티아 (0) | 2021.08.19 |