제출 #173297

#제출 시각아이디문제언어결과실행 시간메모리
173297mosiashvililukaHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
30 / 100
758 ms107972 KiB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f[1000009],i,j,zx,xc,qq,l,r,ar[1000009];
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;
    }
    ar[1]=1;
    for(i=2; i<=a; i++){
    	if(f[i-1]<=f[i]) ar[i]=ar[i-1]; else ar[i]=i;
	}
    for(qq=1; qq<=b; qq++){
        scanf("%d%d%d\n",&l,&r,&e);
        if(ar[r]<=l){
        	printf("1\n");
		}else{
			printf("0\n");
		}
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:5:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d\n",&a,&b);
     ~~~~~^~~~~~~~~~~~~~~~
sortbooks.cpp:6:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=a; i++) scanf("%d",&f[i]);
                         ~~~~~^~~~~~~~~~~~
sortbooks.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("\n");
     ~~~~~^~~~~~
sortbooks.cpp:28:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d%d\n",&l,&r,&e);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d\n",&l,&r,&e);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...