結果

問題 No.1438 Broken Drawers
ユーザー ks2mks2m
提出日時 2021-03-26 21:29:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 678 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 3,444 ms
コンパイル使用メモリ 71,168 KB
実行使用メモリ 66,888 KB
最終ジャッジ日時 2023-08-19 07:06:09
合計ジャッジ時間 16,757 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
55,504 KB
testcase_01 AC 111 ms
55,788 KB
testcase_02 AC 108 ms
56,320 KB
testcase_03 AC 109 ms
55,968 KB
testcase_04 AC 112 ms
55,804 KB
testcase_05 AC 112 ms
56,080 KB
testcase_06 AC 587 ms
64,568 KB
testcase_07 AC 600 ms
64,896 KB
testcase_08 AC 121 ms
55,792 KB
testcase_09 AC 129 ms
55,960 KB
testcase_10 AC 132 ms
55,836 KB
testcase_11 AC 235 ms
59,876 KB
testcase_12 AC 452 ms
60,564 KB
testcase_13 AC 481 ms
62,064 KB
testcase_14 AC 385 ms
60,128 KB
testcase_15 AC 587 ms
64,548 KB
testcase_16 AC 565 ms
64,404 KB
testcase_17 AC 629 ms
64,744 KB
testcase_18 AC 612 ms
64,540 KB
testcase_19 AC 605 ms
64,472 KB
testcase_20 AC 620 ms
64,952 KB
testcase_21 AC 602 ms
64,792 KB
testcase_22 AC 626 ms
64,576 KB
testcase_23 AC 622 ms
64,660 KB
testcase_24 AC 630 ms
64,572 KB
testcase_25 AC 640 ms
64,708 KB
testcase_26 AC 678 ms
64,916 KB
testcase_27 AC 616 ms
66,888 KB
権限があれば一括ダウンロードができます

ソースコード

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