답안 #889895

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889895 2023-12-20T09:19:33 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
17 / 100
2221 ms 100048 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int M = 5001;
const int N=1e6+10;
int aa[N];
int a[M], pref[M];
int ans[M][M];
int main(){
	int n, q;
	cin >> n >> q;
	
	if(n<=5001 && q<=5001){
		
		a[0]=1e9+7;
		for(int i=1; i<=n; i++){
			cin>>a[i];
		}
		for(int i=1; i<=n; i++) {
			pref[i]=i-1;
			while(a[i]>=a[pref[i]]) {
				pref[i]=pref[pref[i]];
			}
		}
		for(int i=1; i<=n; i++){
			ans[i][i]=0;
			for(int j=i+1; j<=n; j++){
				ans[i][j]=ans[i][j-1];
				if(pref[j]>=i){
					ans[i][j]=max(ans[i][j], a[pref[j]] + a[j]);
				}
			}
		}
		while(q--){
			int l, r, k;
			cin >> l >> r >> k;
			if(ans[l][r]<=k){
				cout<<"1\n";
			}
			else{
				cout<<"0\n";
			}
		}
	}
	else{
		bool ok[N];	
		ok[0]=1;
		for(int i=1; i<=n; i++){
			cin>>aa[i];
			if(ok[i-1] && aa[i] >= aa[i-1]){
				ok[i]=1;
			}
		}
		
		for(int i=1; i<=q; i++){
			int l,r,k;
			cin>>l>>r>>k;
			bool ans=1;
			if(ok[r]){
				cout<<ans<<"\n";
				continue;
			}
			for(int i=l; i<r; i++){
				if(aa[i]>aa[i+1]){
					ans=0;
					break;
				}
			}
			cout<<ans<<"\n";
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 2 ms 7516 KB Output is correct
4 Correct 2 ms 5464 KB Output is correct
5 Correct 2 ms 7516 KB Output is correct
6 Correct 3 ms 13660 KB Output is correct
7 Correct 3 ms 13656 KB Output is correct
8 Correct 4 ms 13904 KB Output is correct
9 Correct 3 ms 9564 KB Output is correct
10 Correct 3 ms 13660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 2 ms 7516 KB Output is correct
4 Correct 2 ms 5464 KB Output is correct
5 Correct 2 ms 7516 KB Output is correct
6 Correct 3 ms 13660 KB Output is correct
7 Correct 3 ms 13656 KB Output is correct
8 Correct 4 ms 13904 KB Output is correct
9 Correct 3 ms 9564 KB Output is correct
10 Correct 3 ms 13660 KB Output is correct
11 Correct 13 ms 32136 KB Output is correct
12 Correct 61 ms 99928 KB Output is correct
13 Correct 56 ms 100048 KB Output is correct
14 Correct 60 ms 99920 KB Output is correct
15 Correct 61 ms 99916 KB Output is correct
16 Correct 52 ms 100048 KB Output is correct
17 Correct 38 ms 83536 KB Output is correct
18 Correct 54 ms 99920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2221 ms 8452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 188 ms 3580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 2 ms 7516 KB Output is correct
4 Correct 2 ms 5464 KB Output is correct
5 Correct 2 ms 7516 KB Output is correct
6 Correct 3 ms 13660 KB Output is correct
7 Correct 3 ms 13656 KB Output is correct
8 Correct 4 ms 13904 KB Output is correct
9 Correct 3 ms 9564 KB Output is correct
10 Correct 3 ms 13660 KB Output is correct
11 Correct 13 ms 32136 KB Output is correct
12 Correct 61 ms 99928 KB Output is correct
13 Correct 56 ms 100048 KB Output is correct
14 Correct 60 ms 99920 KB Output is correct
15 Correct 61 ms 99916 KB Output is correct
16 Correct 52 ms 100048 KB Output is correct
17 Correct 38 ms 83536 KB Output is correct
18 Correct 54 ms 99920 KB Output is correct
19 Incorrect 434 ms 8460 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 2 ms 7516 KB Output is correct
4 Correct 2 ms 5464 KB Output is correct
5 Correct 2 ms 7516 KB Output is correct
6 Correct 3 ms 13660 KB Output is correct
7 Correct 3 ms 13656 KB Output is correct
8 Correct 4 ms 13904 KB Output is correct
9 Correct 3 ms 9564 KB Output is correct
10 Correct 3 ms 13660 KB Output is correct
11 Correct 13 ms 32136 KB Output is correct
12 Correct 61 ms 99928 KB Output is correct
13 Correct 56 ms 100048 KB Output is correct
14 Correct 60 ms 99920 KB Output is correct
15 Correct 61 ms 99916 KB Output is correct
16 Correct 52 ms 100048 KB Output is correct
17 Correct 38 ms 83536 KB Output is correct
18 Correct 54 ms 99920 KB Output is correct
19 Incorrect 2221 ms 8452 KB Output isn't correct
20 Halted 0 ms 0 KB -