結果

問題 No.1438 Broken Drawers
ユーザー tentententen
提出日時 2023-04-17 10:04:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 275 ms / 2,000 ms
コード長 1,934 bytes
コンパイル時間 2,545 ms
コンパイル使用メモリ 84,344 KB
実行使用メモリ 48,804 KB
最終ジャッジ日時 2024-04-20 16:26:29
合計ジャッジ時間 9,567 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
37,204 KB
testcase_01 AC 52 ms
37,048 KB
testcase_02 AC 53 ms
37,152 KB
testcase_03 AC 52 ms
37,212 KB
testcase_04 AC 51 ms
37,140 KB
testcase_05 AC 55 ms
37,384 KB
testcase_06 AC 275 ms
48,804 KB
testcase_07 AC 256 ms
46,600 KB
testcase_08 AC 53 ms
37,300 KB
testcase_09 AC 53 ms
37,248 KB
testcase_10 AC 53 ms
36,824 KB
testcase_11 AC 105 ms
39,640 KB
testcase_12 AC 208 ms
44,668 KB
testcase_13 AC 217 ms
45,264 KB
testcase_14 AC 185 ms
44,452 KB
testcase_15 AC 259 ms
47,112 KB
testcase_16 AC 262 ms
47,232 KB
testcase_17 AC 265 ms
47,020 KB
testcase_18 AC 259 ms
47,020 KB
testcase_19 AC 254 ms
47,200 KB
testcase_20 AC 266 ms
47,280 KB
testcase_21 AC 264 ms
47,168 KB
testcase_22 AC 265 ms
47,392 KB
testcase_23 AC 263 ms
47,256 KB
testcase_24 AC 265 ms
47,064 KB
testcase_25 AC 262 ms
47,348 KB
testcase_26 AC 267 ms
47,116 KB
testcase_27 AC 251 ms
47,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int prev = 0;
        int count = 0;
        ArrayList<Integer> sum = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (prev > x) {
                count++;
            } else {
                sum.add(count);
                count = 1;
            }
            prev = x;
        }
        sum.add(count);
        int ans = n;
        for (int x : sum) {
            ans -= x / 2;
        }
        System.out.println(ans);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0