結果

問題 No.1768 The frog in the well knows the great ocean.
ユーザー noshi91
提出日時 2021-11-27 00:56:14
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 626 bytes
コンパイル時間 813 ms
コンパイル使用メモリ 95,064 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-29 19:18:57
合計ジャッジ時間 2,764 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8 WA * 19
権限があれば一括ダウンロードができます

ソースコード

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