結果

問題 No.1438 Broken Drawers
ユーザー ks2m
提出日時 2021-03-26 21:29:31
言語 Java
(openjdk 23)
結果
AC  
実行時間 845 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 3,397 ms
コンパイル使用メモリ 74,336 KB
実行使用メモリ 65,124 KB
最終ジャッジ日時 2024-11-28 21:31:40
合計ジャッジ時間 19,393 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int ans = 1;
		int cnt = 0;
		for (int i = 1; i < n; i++) {
			if (a[i - 1] < a[i]) {
				ans++;
				ans += cnt / 2;
				cnt = 0;
			} else {
				cnt++;
			}
		}
		ans += cnt / 2;
		System.out.println(ans);
	}
}
0