백준 문제풀이/Implementation
[C++] 백준 문제풀이 (Implementation) 17608번 막대기
코딩준우
2023. 6. 26. 16:37
https://www.acmicpc.net/problem/17608
17608번: 막대기
아래 그림처럼 높이만 다르고 (같은 높이의 막대기가 있을 수 있음) 모양이 같은 막대기를 일렬로 세운 후, 왼쪽부터 차례로 번호를 붙인다. 각 막대기의 높이는 그림에서 보인 것처럼 순서대로
www.acmicpc.net
//[C++] 백준 문제풀이 (Implementation)
#include <bits/stdc++.h>
int state[100000];
int main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
for (int i = 0; i < n; ++i){
std::cin >> state[i];
}
int max = state[n - 1];
int cnt = 1;
for (int i = n - 2; i >= 0; --i){
if (state[i] > max){
++cnt;
max = state[i];
}
}
std::cout << cnt << "\n";
return 0;
}