알고리즘/BOJ

백준 25527번 Counting Peaks of Infection

꾸준함. 2022. 8. 31. 22:32

문제 링크입니다: 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

간단한 구현 문제였습니다.

 

#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;
}
view raw .cpp hosted with ❤ by GitHub

 

개발환경:Visual Studio 2022

 

지적, 조언, 질문 환영입니다! 댓글 남겨주세요~

반응형