제출 #996359

#제출 시각아이디문제언어결과실행 시간메모리
996359vladiliusGift Exchange (JOI24_ho_t4)C++17
0 / 100
2571 ms6272 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second #define ins insert #define arr3 array<int, 3> int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; vector<int> a(n + 1), b(n + 1); 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> x; set<pii> st; for (int i = l; i <= r; i++){ x.pb(i); st.ins({a[i], i}); } auto cmp = [&](int i, int j){ return b[i] > b[j]; }; sort(x.begin(), x.end(), cmp); bool ind = 1; for (int i: x){ auto it = st.find({a[i], i}); bool k = (it != st.end()); if (k) st.erase(it); it = st.lower_bound({b[i], 0}); if (it == st.end()){ ind = 0; break; } st.erase(it); if (k) st.ins({a[i], i}); } cout<<((ind) ? "Yes" : "No")<<"\n"; } }
#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...