結果

問題 No.905 Sorted?
ユーザー tentententen
提出日時 2020-08-27 09:48:32
言語 Java19
(openjdk 21)
結果
AC  
実行時間 1,011 ms / 2,000 ms
コード長 1,271 bytes
コンパイル時間 3,326 ms
コンパイル使用メモリ 74,156 KB
実行使用メモリ 67,836 KB
最終ジャッジ日時 2023-08-07 11:35:14
合計ジャッジ時間 15,475 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
56,148 KB
testcase_01 AC 136 ms
56,100 KB
testcase_02 AC 132 ms
55,936 KB
testcase_03 AC 136 ms
55,848 KB
testcase_04 AC 133 ms
55,796 KB
testcase_05 AC 213 ms
58,988 KB
testcase_06 AC 199 ms
58,404 KB
testcase_07 AC 267 ms
60,028 KB
testcase_08 AC 797 ms
64,524 KB
testcase_09 AC 658 ms
63,564 KB
testcase_10 AC 871 ms
64,596 KB
testcase_11 AC 833 ms
66,252 KB
testcase_12 AC 811 ms
66,340 KB
testcase_13 AC 863 ms
65,652 KB
testcase_14 AC 938 ms
65,644 KB
testcase_15 AC 786 ms
67,836 KB
testcase_16 AC 929 ms
66,892 KB
testcase_17 AC 871 ms
67,060 KB
testcase_18 AC 1,011 ms
65,260 KB
testcase_19 AC 120 ms
56,016 KB
testcase_20 AC 119 ms
55,944 KB
testcase_21 AC 117 ms
55,400 KB
testcase_22 AC 117 ms
56,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] asc = new int[n];
        int[] dsc = new int[n];
        asc[0] = 1;
        dsc[0] = 1;
        long prev = sc.nextLong();
        for (int i = 1; i < n; i++) {
            long x = sc.nextLong();
            if (prev <= x) {
                asc[i] = asc[i - 1] + 1;
            } else {
                asc[i] = 1;
            }
            if (prev >= x) {
                dsc[i] = dsc[i - 1] + 1;
            } else {
                dsc[i] = 1;
            }
            prev = x;
        }
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int left = sc.nextInt();
            int right = sc.nextInt();
            if (asc[right] - asc[left] == right - left) {
                sb.append(1);
            } else {
                sb.append(0);
            }
            sb.append(" ");
            if (dsc[right] - dsc[left] == right - left) {
                sb.append(1);
            } else {
                sb.append(0);
            }
            sb.append("\n");
       }
       System.out.print(sb);
    }
}
0