# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
173286 | mosiashvililuka | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 187 ms | 4244 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<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f[1000009],i,j,zx,xc,qq,l,r;
int main(){
scanf("%d%d\n",&a,&b);
for(i=1; i<=a; i++) scanf("%d",&f[i]);
scanf("\n");
if(a<=5000){
short z[5009][5009],x[5009][5009];
int mx[5009][5009];
for(i=1; i<=a; i++){
z[i][0]=0;
for(j=1; j<i; j++){
if(f[j]<=f[i]) z[i][j]=z[i][j-1]+1; else z[i][j]=z[i][j-1];
}
x[i][a+1]=0;
for(j=a; j>i; j--){
if(f[j]<f[i]) x[i][j]=x[i][j+1]+1; else x[i][j]=x[i][j+1];
}
}
for(i=1; i<=a; i++){
mx[i][i]=f[i];
for(j=i-1; j>=1; j--){
if(mx[j+1][i]<=f[j]) mx[j][i]=f[j]; else mx[j][i]=mx[j+1][i];
}
}
for(qq=1; qq<=b; qq++){
scanf("%d%d%d\n",&l,&r,&e);
// return 0;
bool bo=0;
for(i=l; i<=r; i++){
c=z[i][i-1];
c=c-z[i][l-1];
// if(qq==2) cout<<f[i]<<" "<<c<<endl;
// if(l+c<i){
if(mx[l][i-1]+f[i]>e){
bo=1;
break;
}
// }
}
if(bo==0) printf("1\n"); else printf("0\n");
}
}
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... |