結果

問題 No.905 Sorted?
ユーザー htensaihtensai
提出日時 2019-11-11 09:48:24
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 959 bytes
コンパイル時間 1,993 ms
コンパイル使用メモリ 74,232 KB
実行使用メモリ 67,220 KB
最終ジャッジ日時 2023-10-13 07:58:40
合計ジャッジ時間 12,696 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
39,652 KB
testcase_01 AC 115 ms
40,052 KB
testcase_02 AC 110 ms
39,584 KB
testcase_03 AC 112 ms
39,188 KB
testcase_04 AC 112 ms
39,200 KB
testcase_05 AC 198 ms
43,624 KB
testcase_06 AC 189 ms
41,228 KB
testcase_07 AC 251 ms
45,348 KB
testcase_08 RE -
testcase_09 AC 606 ms
63,636 KB
testcase_10 RE -
testcase_11 AC 755 ms
64,904 KB
testcase_12 AC 847 ms
52,820 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 744 ms
66,232 KB
testcase_16 AC 793 ms
66,856 KB
testcase_17 AC 736 ms
67,220 KB
testcase_18 AC 689 ms
64,752 KB
testcase_19 AC 107 ms
55,924 KB
testcase_20 AC 109 ms
55,760 KB
testcase_21 AC 112 ms
55,972 KB
testcase_22 AC 112 ms
55,812 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[] fArr = new int[n];
		int[] gArr = new int[n];
		int prev = sc.nextInt();
		for (int i = 1; i < n; i++) {
		    int x = sc.nextInt();
		    if (prev <= x) {
		        fArr[i] = fArr[i - 1];
		    } else {
		        fArr[i] = i;
		    }
		    if (prev >= x) {
		        gArr[i] = gArr[i - 1];
		    } else {
		        gArr[i] = i;
		    }
		    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 (fArr[right] <= left) {
		        sb.append(1);
		    } else {
		        sb.append(0);
		    }
		    sb.append(" ");
		    if (gArr[right] <= left) {
		        sb.append(1);
		    } else {
		        sb.append(0);
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
}
0