結果

問題 No.905 Sorted?
ユーザー tentententen
提出日時 2020-08-27 09:47:15
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,267 bytes
コンパイル時間 1,990 ms
コンパイル使用メモリ 74,428 KB
実行使用メモリ 66,924 KB
最終ジャッジ日時 2023-08-07 11:34:56
合計ジャッジ時間 12,206 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
56,212 KB
testcase_01 AC 137 ms
56,048 KB
testcase_02 AC 133 ms
56,084 KB
testcase_03 AC 136 ms
55,672 KB
testcase_04 AC 135 ms
56,004 KB
testcase_05 AC 211 ms
58,908 KB
testcase_06 AC 195 ms
58,564 KB
testcase_07 AC 261 ms
59,852 KB
testcase_08 RE -
testcase_09 AC 622 ms
63,656 KB
testcase_10 RE -
testcase_11 AC 798 ms
66,860 KB
testcase_12 AC 771 ms
66,464 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 756 ms
65,952 KB
testcase_16 AC 842 ms
66,924 KB
testcase_17 AC 803 ms
66,764 KB
testcase_18 AC 721 ms
64,628 KB
testcase_19 AC 118 ms
58,024 KB
testcase_20 AC 118 ms
55,568 KB
testcase_21 AC 120 ms
55,988 KB
testcase_22 AC 117 ms
55,884 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;
        int prev = sc.nextInt();
        for (int i = 1; i < n; i++) {
            int x = sc.nextInt();
            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