結果

問題 No.1768 The frog in the well knows the great ocean.
ユーザー noshi91noshi91
提出日時 2021-11-27 00:56:14
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 626 bytes
コンパイル時間 1,101 ms
コンパイル使用メモリ 94,104 KB
実行使用メモリ 4,676 KB
最終ジャッジ日時 2023-09-12 06:14:11
合計ジャッジ時間 3,063 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 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 35 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 35 ms
4,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 38 ms
4,624 KB
testcase_20 AC 38 ms
4,632 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 34 ms
4,608 KB
testcase_27 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>

bool solve() {
  int N;
  std::cin >> N;
  std::vector<int> A(N), B(N);
  for (int &a : A) {
    std::cin >> a;
  }
  for (int &b : B) {
    std::cin >> b;
  }

  int max = 0;
  for (int i = 0; i < N; i++) {
    max = std::max(max, A[i]);
    if (i + 1 == N || B[i] != B[i + 1]) {
      if (max != B[i]) {
        return false;
      }
      max = 0;
    }
  }

  return true;
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int T;
  std::cin >> T;
  while (T--) {
    std::cout << (solve() ? "Yes" : "No") << "\n";
  }

  return 0;
}
0