結果

問題 No.905 Sorted?
ユーザー htensaihtensai
提出日時 2019-11-11 09:49:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,026 ms / 2,000 ms
コード長 963 bytes
コンパイル時間 2,040 ms
コンパイル使用メモリ 73,616 KB
実行使用メモリ 67,120 KB
最終ジャッジ日時 2023-10-13 07:58:56
合計ジャッジ時間 15,469 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,828 KB
testcase_01 AC 141 ms
55,756 KB
testcase_02 AC 133 ms
56,196 KB
testcase_03 AC 138 ms
55,880 KB
testcase_04 AC 138 ms
55,812 KB
testcase_05 AC 216 ms
58,988 KB
testcase_06 AC 197 ms
58,328 KB
testcase_07 AC 271 ms
60,320 KB
testcase_08 AC 824 ms
64,600 KB
testcase_09 AC 663 ms
64,868 KB
testcase_10 AC 889 ms
62,848 KB
testcase_11 AC 852 ms
66,188 KB
testcase_12 AC 845 ms
66,380 KB
testcase_13 AC 928 ms
65,896 KB
testcase_14 AC 1,026 ms
66,036 KB
testcase_15 AC 851 ms
66,336 KB
testcase_16 AC 932 ms
66,760 KB
testcase_17 AC 875 ms
67,120 KB
testcase_18 AC 805 ms
64,932 KB
testcase_19 AC 123 ms
56,116 KB
testcase_20 AC 122 ms
56,144 KB
testcase_21 AC 121 ms
55,728 KB
testcase_22 AC 121 ms
56,280 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];
		long prev = sc.nextLong();
		for (int i = 1; i < n; i++) {
		    long x = sc.nextLong();
		    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