結果

問題 No.1438 Broken Drawers
ユーザー tenten
提出日時 2021-03-30 10:56:45
言語 Java
(openjdk 23)
結果
AC  
実行時間 835 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 2,213 ms
コンパイル使用メモリ 74,468 KB
実行使用メモリ 53,356 KB
最終ジャッジ日時 2024-11-30 08:11:53
合計ジャッジ時間 19,531 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int prev = Integer.MIN_VALUE;
        int ans = 0;
        int count = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (prev > x) {
                count++;
            } else {
                ans += count / 2;
                count = 1;
            }
            prev = x;
        }
        ans += count / 2;
        System.out.println(n - ans);
    }
}
0