Submission #1124727

#TimeUsernameProblemLanguageResultExecution timeMemory
1124727peacebringer1667Gift Exchange (JOI24_ho_t4)C++17
10 / 100
36 ms2244 KiB
#include<bits/stdc++.h> #define ll long long #define ldb long double #define db double #define fi first #define se second #define sza(a) (int)a.size() #define pir pair<int,int> #define pirll pair<ll,ll> using namespace std; const int maxn = 1e5 + 5; template <class t1,class t2> inline void maxi(t1 &x,t2 y){if (x < y) x = y;} template <class t1,class t2> inline void mini(t1 &x,t2 y){if (x > y) x = y;} int a[maxn],b[maxn]; pir Q[maxn]; void input(int &n,int &q){ cin >> n; for (int i = 1 ; i <= n ; i++) cin >> a[i]; for (int i = 1 ; i <= n ; i++) cin >> b[i]; cin >> q; for (int i = 1 ; i <= q ; i++) cin >> Q[i].fi >> Q[i].se; } bool possible(int l,int r){ vector <pir> lst; for (int i = l ; i <= r ; i++) lst.push_back({a[i],b[i]}); sort(lst.begin(),lst.end()); int M = lst[0].se; for (pir x : lst) if (M >= x.se) maxi(M,x.fi); return (M >= lst.back().se); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); int n,q; input(n,q); assert(n * q <= 10000000); //subtask1 for (int i = 1 ; i <= q ; i++){ cout << ((possible(Q[i].fi,Q[i].se) ? "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...