結果

問題 No.1768 The frog in the well knows the great ocean.
ユーザー tentententen
提出日時 2021-11-27 16:14:59
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,975 bytes
コンパイル時間 2,633 ms
コンパイル使用メモリ 75,020 KB
実行使用メモリ 66,452 KB
最終ジャッジ日時 2023-09-12 19:20:52
合計ジャッジ時間 11,768 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,304 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 336 ms
62,024 KB
testcase_13 WA -
testcase_14 AC 344 ms
61,992 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 343 ms
64,040 KB
testcase_20 AC 389 ms
64,212 KB
testcase_21 AC 45 ms
49,364 KB
testcase_22 AC 46 ms
49,224 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 373 ms
63,772 KB
testcase_27 AC 43 ms
49,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int t = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        while (t-- > 0) {
            int n = sc.nextInt();
            int[] valueA = new int[n];
            for (int i = 0; i < n; i++) {
                valueA[i] = sc.nextInt();
            }
            int[] valueB = new int[n];
            for (int i = 0; i < n; i++) {
                valueB[i] = sc.nextInt();
            }
            int left = 0;
            int right = 0;
            boolean ok = true;
            while (ok & left < n) {
                while (right < n - 1 && valueB[right + 1] == valueB[left]) {
                    right++;
                }
                int max = 0;
                for (int i = left; i <= right; i++) {
                    max = Math.max(max, valueA[i]);
                }
                ok = (max == valueB[left]);
                left = right + 1;
                right = left;
            }
            if (ok) {
                sb.append("Yes");
            } else {
                sb.append("No");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0