結果

問題 No.905 Sorted?
ユーザー tentententen
提出日時 2020-08-27 09:47:15
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 1,267 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 77,636 KB
実行使用メモリ 59,552 KB
最終ジャッジ日時 2024-11-07 15:29:14
合計ジャッジ時間 13,292 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 RE * 4
権限があれば一括ダウンロードができます

ソースコード

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