# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
339048 | Khizri | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 3067 ms | 33776 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
//------------------------------------------------------------------------------
//******************************************************************************
#define IOS ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0)
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define ll long long
#define MOD 1e9+7
#define endl '\n'
const int mxn=1e6+5;
//******************************************************************************
//------------------------------------------------------------------------------
ll t=1,n,m,arr[mxn],l,r,k;
bool funk(){
multiset<ll>st;
for(int i=l;i<=r;i++){
st.insert(arr[i]);
}
for(int i=l;i<=r;i++){
st.erase(st.find(arr[i]));
multiset<ll>::iterator it=st.lower_bound(arr[i]);
if(it!=st.begin()){
it--;
if((*it)+arr[i]>k){
return false;
}
}
}
return true;
}
void solve(){
scanf("%lld %lld",&n,&m);
for(int i=1;i<=n;i++){
scanf("%lld",&arr[i]);
}
while(m--){
scanf("%lld %lld %lld",&l,&r,&k);
int q=funk();
printf("%d\n",q);
}
}
int main(){
//IOS;
//cin>>t;
while(t--){
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |