COI2019 초등부 문제 (막대기)

han.user();·2023년 4월 11일
0

구름

목록 보기
18/20
post-thumbnail

import java.io.*;

class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //    같거나 작은건 안보임. 뒤와 맨뒤를 기준으로 큰것만 보임

        int howmany = Integer.parseInt(br.readLine());

        int[] stickHeight = new int[howmany];

        for (int i = 0; i < howmany; i++) {
            stickHeight[i] = Integer.parseInt(br.readLine());
        }

        int count = 0;
        int max = 0;

        for (int i = stickHeight.length-2; i >= 0; i--) {
            if (stickHeight[i] > max) {
                max = stickHeight[i];
                if (stickHeight[i] > stickHeight[stickHeight.length - 1] && stickHeight[i] >= max) {
                    count++;
                } else {
                    continue;
                }
            }
        }
        System.out.println(count+1);
    }
}
profile
I'm still hungry.

0개의 댓글