제출 #1107877

#제출 시각아이디문제언어결과실행 시간메모리
1107877_callmelucianGift Exchange (JOI24_ho_t4)C++14
50 / 100
2555 ms6260 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pl; typedef pair<int,int> pii; typedef tuple<int,int,int> tt; #define all(a) a.begin(), a.end() #define filter(a) a.erase(unique(all(a)), a.end()) bool solve (vector<int> a, vector<int> b, int n) { vector<int> p(n); for (int i = 0; i < n; i++) p[i] = i; sort(all(p), [&] (int i, int j) { return b[i] < b[j]; }); bool pre = 0; int maxCur = 0; for (int i = 0; i < n; i++) { maxCur = max(maxCur, a[p[i]]); bool cur = (i + 1 < n && b[p[i + 1]] < maxCur); if (!pre && !cur) return 0; if (!cur) maxCur = 0; pre = cur; } return 1; } const int mn = 5e5 + 5; int a[mn], b[mn]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; int q; cin >> q; while (q--) { int l, r; cin >> l >> r; vector<int> vec_a, vec_b; for (int i = l; i <= r; i++) { vec_a.push_back(a[i]); vec_b.push_back(b[i]); } cout << (solve(vec_a, vec_b, r - l + 1) ? "Yes" : "No") << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...