結果
問題 | No.1768 The frog in the well knows the great ocean. |
ユーザー | startcpp |
提出日時 | 2021-11-26 23:38:18 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,220 bytes |
コンパイル時間 | 655 ms |
コンパイル使用メモリ | 74,964 KB |
実行使用メモリ | 6,860 KB |
最終ジャッジ日時 | 2023-09-12 06:01:32 |
合計ジャッジ時間 | 4,294 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 5 ms
4,380 KB |
testcase_02 | AC | 6 ms
4,380 KB |
testcase_03 | AC | 5 ms
4,380 KB |
testcase_04 | AC | 5 ms
4,376 KB |
testcase_05 | AC | 5 ms
4,380 KB |
testcase_06 | AC | 106 ms
4,376 KB |
testcase_07 | AC | 106 ms
5,080 KB |
testcase_08 | AC | 103 ms
4,904 KB |
testcase_09 | AC | 104 ms
4,380 KB |
testcase_10 | AC | 104 ms
4,732 KB |
testcase_11 | AC | 108 ms
5,412 KB |
testcase_12 | AC | 106 ms
5,172 KB |
testcase_13 | AC | 108 ms
5,148 KB |
testcase_14 | AC | 107 ms
5,220 KB |
testcase_15 | WA | - |
testcase_16 | AC | 115 ms
6,684 KB |
testcase_17 | AC | 115 ms
6,784 KB |
testcase_18 | AC | 114 ms
6,796 KB |
testcase_19 | AC | 113 ms
6,796 KB |
testcase_20 | AC | 113 ms
6,792 KB |
testcase_21 | AC | 1 ms
4,380 KB |
testcase_22 | AC | 1 ms
4,376 KB |
testcase_23 | AC | 3 ms
4,380 KB |
testcase_24 | WA | - |
testcase_25 | AC | 111 ms
6,860 KB |
testcase_26 | AC | 102 ms
6,740 KB |
testcase_27 | AC | 1 ms
4,380 KB |
ソースコード
//スライド最大値でもできるけど、面倒くさいのでセグ木で殴る #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; }