Submission #1095747

#TimeUsernameProblemLanguageResultExecution timeMemory
1095747vladiliusGift Exchange (JOI24_ho_t4)C++17
0 / 100
1 ms456 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 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; priority_queue<pii, vector<pii>, less<pii>> p1, p2; for (int i = l; i <= r; i++){ p1.push({a[i], i}); p2.push({b[i], i}); } bool ind = 1; while (!p2.empty()){ if (p1.top().ss != p2.top().ss){ if (p1.top().ff < p2.top().ff){ ind = 0; break; } p1.pop(); p2.pop(); continue; } if (p1.size() == 1){ ind = 0; break; } pii x = p1.top(); p1.pop(); if (p1.top().ff < p2.top().ff){ ind = 0; break; } p1.pop(); p2.pop(); p1.push(x); } 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...