제출 #996294

#제출 시각아이디문제언어결과실행 시간메모리
996294MilosMilutinovicGift Exchange (JOI24_ho_t4)C++14
50 / 100
2549 ms5288 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> b(n); for (int i = 0; i < n; i++) { cin >> b[i]; } int q; cin >> q; while (q--) { int l, r; cin >> l >> r; --l; --r; vector<pair<int, int>> ev; for (int i = l; i <= r; i++) { ev.emplace_back(b[i], +1); ev.emplace_back(a[i], -1); } sort(ev.begin(), ev.end()); bool ok = true; int bal = 0; int mx = 0; for (auto& p : ev) { int v = p.second; bal += v; if (bal < 0) { ok = false; } if (bal == 0) { if (mx <= 1) { ok = false; } mx = 0; } mx = max(mx, bal); } cout << (ok ? "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...