본문 바로가기

Coding Test/백준

[백준/자바] 28014 - 첨탑 밀어서 부수기

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        int[] arr = new int[n];
        StringTokenizer st = new StringTokenizer(br.readLine());
        for (int i = 0; i < n; i++) arr[i] = Integer.parseInt(st.nextToken());

        int result = n;
        for(int i=0; i<n-1; i++){
            if(arr[i] > arr[i+1]) result--;
        }

        System.out.println(result);

        br.close();
    }
}