結果

問題 No.905 Sorted?
ユーザー 37zigen37zigen
提出日時 2019-09-30 21:35:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,314 ms / 2,000 ms
コード長 1,436 bytes
コンパイル時間 2,639 ms
コンパイル使用メモリ 80,020 KB
実行使用メモリ 72,232 KB
最終ジャッジ日時 2024-04-14 08:50:09
合計ジャッジ時間 19,824 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 164 ms
55,076 KB
testcase_01 AC 175 ms
55,176 KB
testcase_02 AC 173 ms
55,004 KB
testcase_03 AC 168 ms
55,196 KB
testcase_04 AC 170 ms
55,056 KB
testcase_05 AC 280 ms
58,188 KB
testcase_06 AC 249 ms
58,456 KB
testcase_07 AC 345 ms
60,136 KB
testcase_08 AC 1,118 ms
71,916 KB
testcase_09 AC 939 ms
67,064 KB
testcase_10 AC 1,132 ms
72,036 KB
testcase_11 AC 1,109 ms
71,848 KB
testcase_12 AC 1,102 ms
71,256 KB
testcase_13 AC 1,231 ms
72,004 KB
testcase_14 AC 1,304 ms
71,476 KB
testcase_15 AC 1,176 ms
72,232 KB
testcase_16 AC 1,314 ms
72,028 KB
testcase_17 AC 1,282 ms
71,604 KB
testcase_18 AC 1,177 ms
71,816 KB
testcase_19 AC 161 ms
54,880 KB
testcase_20 AC 172 ms
55,132 KB
testcase_21 AC 158 ms
55,068 KB
testcase_22 AC 160 ms
54,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 制約侵害の有無 確認

import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.*;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {
    	new Main().run();
    }
    
    void run() {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
    	long[] A = new long[N];
    	for (int i = 0; i < N; ++i) {
	        A[i] = sc.nextLong();
	    }
    	long[] sumUp = new long[N];
    	long[] sumDn = new long[N];
    	for (int i = 1; i < N; ++i) {
	        if (A[i] >= A[i - 1])
		        sumUp[i] = sumUp[i - 1] + 1;
	         if (A[i] <= A[i - 1])
		        sumDn[i] = sumDn[i - 1] + 1;
	    }
	    PrintWriter pw = new PrintWriter(System.out);
	    int Q = sc.nextInt();
	    int[] l = new int[Q];
	    int[] r = new int[Q];
	    for (int i = 0; i < Q; ++i) {
	        l[i] = sc.nextInt();
	        r[i] = sc.nextInt();
	        boolean up = sumUp[r[i]] >= r[i] - l[i];
	        boolean dn = sumDn[r[i]] >= r[i] - l[i];
	    	pw.println((up ? 1 : 0) + " " + (dn ? 1 : 0));
        }
	    pw.close();
	    if (!(1 <= N && N <= 1e5) || !(1 <= Q && Q <= 1e5)) throw new AssertionError();
	    for (int i = 0; i < N; ++i) {
	        if (!(-1e18 <= A[i] && A[i] <= 1e18)) throw new AssertionError();
	    }
	    for (int i = 0; i < Q; ++i) {
	        if (!(0 <= l[i] && l[i] <= r[i] && r[i] <= N - 1)) throw new AssertionError(); 
	    }
    }
}
0