답안 #690292

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
690292 2023-01-30T05:47:34 Z iskhakkutbilim Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
13 / 100
468 ms 14256 KB
#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int N = 1e6;
const int M = 1e9+7;

int n, q;
int a[N], pref[N], sum[N];
int get_sum(int l,int r){
	return (sum[r] - (l > 0 ? sum[l-1] : 0));
}

main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
	cin >> n >> q;
	int mn = INT_MAX;
	for(int i = 0;i < n; i++){
		cin >> a[i];
		sum[i] = a[i] + (i > 0 ? sum[i-1] : 0);
		mn = min(mn, a[i]);
	}
	for(int i = 0;i < n-1; i++){
		if(i == 0){
			pref[i] = (a[i+1]>=a[i]);
		}else{
			pref[i] = pref[i-1]+ (a[i+1]>= a[i]);
		}
	}
	while(q--){
		int l, r, k; cin >> l >> r >> k; l--, r--;
		if(r-l+1 == 1){
			cout << 1 << '\n';
			continue;
		}
		if(mn > k){
		 	if(pref[max(r-1, 0)]- (l > 0 ? pref[l-1] : 0) == r-l){
		 		cout << 1;
			 }else{
			 	cout << 0;
			 }
			 cout << '\n';
		}else{
			assert(false);
		}
	}
	return 0;
}

Compilation message

sortbooks.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   17 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 410 ms 14016 KB Output is correct
2 Correct 456 ms 14256 KB Output is correct
3 Correct 422 ms 14004 KB Output is correct
4 Correct 452 ms 14140 KB Output is correct
5 Correct 468 ms 14032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 2900 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -