結果
問題 | No.905 Sorted? |
ユーザー | k_6101 |
提出日時 | 2019-12-05 17:53:37 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,152 ms / 2,000 ms |
コード長 | 1,869 bytes |
コンパイル時間 | 2,378 ms |
コンパイル使用メモリ | 79,372 KB |
実行使用メモリ | 68,780 KB |
最終ジャッジ日時 | 2024-06-01 07:40:14 |
合計ジャッジ時間 | 16,005 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 134 ms
54,204 KB |
testcase_01 | AC | 144 ms
53,992 KB |
testcase_02 | AC | 139 ms
53,904 KB |
testcase_03 | AC | 142 ms
54,288 KB |
testcase_04 | AC | 141 ms
54,220 KB |
testcase_05 | AC | 209 ms
56,396 KB |
testcase_06 | AC | 181 ms
54,452 KB |
testcase_07 | AC | 240 ms
58,320 KB |
testcase_08 | AC | 734 ms
63,268 KB |
testcase_09 | AC | 701 ms
60,744 KB |
testcase_10 | AC | 939 ms
64,460 KB |
testcase_11 | AC | 764 ms
63,248 KB |
testcase_12 | AC | 876 ms
64,272 KB |
testcase_13 | AC | 1,152 ms
68,780 KB |
testcase_14 | AC | 1,110 ms
66,432 KB |
testcase_15 | AC | 860 ms
66,784 KB |
testcase_16 | AC | 838 ms
64,144 KB |
testcase_17 | AC | 843 ms
64,000 KB |
testcase_18 | AC | 753 ms
62,484 KB |
testcase_19 | AC | 130 ms
53,956 KB |
testcase_20 | AC | 121 ms
53,012 KB |
testcase_21 | AC | 132 ms
53,756 KB |
testcase_22 | AC | 132 ms
54,056 KB |
ソースコード
import java.io.InputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; import java.util.TreeSet; import static java.util.Comparator.*; public class Main { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); Solver solver = new Solver(System.in, out); solver.solve(); out.close(); } } class Solver { Scanner sc; PrintWriter out; public Solver(InputStream in, PrintWriter out) { sc = new Scanner(in); this.out = out; } // ================================================================== public void solve() { int N = Integer.parseInt(sc.next()); long a, sv; int[] up = new int[N]; int[] down = new int[N]; sv = Long.parseLong(sc.next()); for (int i = 1; i < N; i++) { a = Long.parseLong(sc.next()); if(sv < a) up[i] = 1; else if(sv > a) down[i] = 1; sv = a; } for (int i = 1; i < N; i++) { up[i] += up[i-1]; down[i] += down[i-1]; } int Q = Integer.parseInt(sc.next()); int l, r, uCnt, dCnt; for (int i = 0; i < Q; i++) { l = Integer.parseInt(sc.next()); r = Integer.parseInt(sc.next()); uCnt = up[r] - up[l]; dCnt = down[r] - down[l]; if(uCnt == 0 && dCnt == 0) out.println("1 1"); else if(uCnt > 0 && dCnt == 0) out.println("1 0"); else if(uCnt == 0 && dCnt > 0) out.println("0 1"); else out.println("0 0"); } } // ================================================================== } class PP{ public int key, val; public PP(int key, int val) { this.key = key; this.val = val; } public int getKey() { return key; } public int getVal() { return val; } }