結果
| 問題 | No.1768 The frog in the well knows the great ocean. |
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2021-11-26 23:38:18 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,220 bytes |
| 記録 | |
| コンパイル時間 | 740 ms |
| コンパイル使用メモリ | 78,656 KB |
| 実行使用メモリ | 6,912 KB |
| 最終ジャッジ日時 | 2024-06-29 19:06:20 |
| 合計ジャッジ時間 | 3,840 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 WA * 2 |
ソースコード
//スライド最大値でもできるけど、面倒くさいのでセグ木で殴る
#include <iostream>
#include <atcoder/segtree>
#include <algorithm>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
using namespace atcoder;
int op(int a, int b) { return max(a, b); }
int e() { return -1; }
signed main() {
int T; cin >> T;
while (T--) {
int i, n;
cin >> n;
vector<int> a(n), b(n);
rep(i, n) cin >> a[i];
rep(i, n) cin >> b[i];
segtree<int, op, e> seg(a);
int maxA = 0, maxB = 0;
rep(i, n) maxA = max(maxA, a[i]);
rep(i, n) maxB = max(maxB, b[i]);
if (maxA != maxB) { cout << "No" << endl; continue; }
rep(i, n) if (a[i] > b[i]) break;
if (i < n) { cout << "No" << endl; continue; }
int left = 0;
int cor = 0;
rep(i, n + 1) {
if (i > 0 && (b[i - 1] != b[i] || i == n)) {
for (; cor < n; cor++) {
if (a[cor] == b[i - 1]) {
break;
}
}
if (cor == n) { break; }
int l = min(i, cor);
int r = max(i, cor + 1);
int res = seg.prod(l, r); //[l, r)
if (res > a[cor]) { break; }
left = i;
}
}
if (i < n + 1) {
cout << "No" << endl;
}
else {
cout << "Yes" << endl;
}
}
return 0;
}
startcpp