結果
問題 | No.1768 The frog in the well knows the great ocean. |
ユーザー |
![]() |
提出日時 | 2021-11-26 23:38:18 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.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 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 5 ms
5,376 KB |
testcase_02 | AC | 5 ms
5,376 KB |
testcase_03 | AC | 5 ms
5,376 KB |
testcase_04 | AC | 5 ms
5,376 KB |
testcase_05 | AC | 5 ms
5,376 KB |
testcase_06 | AC | 101 ms
5,376 KB |
testcase_07 | AC | 100 ms
5,376 KB |
testcase_08 | AC | 98 ms
5,376 KB |
testcase_09 | AC | 99 ms
5,376 KB |
testcase_10 | AC | 99 ms
5,376 KB |
testcase_11 | AC | 103 ms
5,376 KB |
testcase_12 | AC | 106 ms
5,376 KB |
testcase_13 | AC | 103 ms
5,376 KB |
testcase_14 | AC | 101 ms
5,376 KB |
testcase_15 | WA | - |
testcase_16 | AC | 111 ms
6,784 KB |
testcase_17 | AC | 109 ms
6,784 KB |
testcase_18 | AC | 111 ms
6,912 KB |
testcase_19 | AC | 107 ms
6,656 KB |
testcase_20 | AC | 108 ms
6,784 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 3 ms
5,376 KB |
testcase_24 | WA | - |
testcase_25 | AC | 104 ms
6,912 KB |
testcase_26 | AC | 99 ms
6,784 KB |
testcase_27 | AC | 2 ms
5,376 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; }