답안 #964885

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964885 2024-04-17T16:56:54 Z Acanikolic Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
17 / 100
3000 ms 41276 KB
#include <bits/stdc++.h>
		 		
//#define int long long 
		 
#define pb push_back 
		
#define F first
		 
#define S second
		 
using namespace std;
		 
const int N = 1000000 + 10;
		 
const int mod = 1e9 + 7;
		 
const int inf = 1e9; 	

int a[N];
vector<pair<int,int>>kveri[N];
	 		 
bool cmp(pair<pair<int,int>,int>A,pair<pair<int,int>,int>B) {
	if(A.F.S < B.F.S) return true;
	return false;
}	 

long long fenw[N];

void update(int index,int n,int val) {
	while(index <= n) {
		fenw[index] += val;
		index += index & -index;
	}
}

long long get(int index) {
	long long ret = 0;
	while(index >= 1) {
		ret += fenw[index];
		index -= index & -index;
	}
	return ret;
}

long long get(int l,int r) {
	return get(r) - get(l - 1);
}
	 		 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	
	int n,q;
	cin >> n >> q;
	vector<int>a(n + 1);
	for(int i = 1; i <= n; i++) cin >> a[i];
	/*vector<int>prev(n + 1,-1);
	stack<int>st;
	for(int i = 1; i <= n; i++) {
		while(st.size() && a[st.top()] <= a[i]) st.pop();
		if(st.size()) prev[i] = st.top();
		st.push(i);
	}
	for(int i = 1; i <= q; i++) {
		int l,r,k;
		cin >> l >> r >> k;
		kveri[r].pb({l,k});
	}
	for(int i = 1; i <= n; i++) {
		if(prev[i] != -1) update(prev[i],n,a[prev[i]] + )
	}*/
	while(q--) {
		int l,r,k;
		cin >> l >> r >> k;
		int mx = 0;
		bool ok = true;
		for(int i = l; i <= r; i++) {
			if(mx > a[i]) {
				if(mx + a[i] > k) ok = false;
			}
			mx = max(mx,a[i]);
		}
		cout << ok << "\n";
	}
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 26972 KB Output is correct
2 Correct 6 ms 26972 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 26972 KB Output is correct
5 Correct 8 ms 26972 KB Output is correct
6 Correct 6 ms 27224 KB Output is correct
7 Correct 6 ms 27096 KB Output is correct
8 Correct 6 ms 26972 KB Output is correct
9 Correct 6 ms 26972 KB Output is correct
10 Correct 6 ms 26972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 26972 KB Output is correct
2 Correct 6 ms 26972 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 26972 KB Output is correct
5 Correct 8 ms 26972 KB Output is correct
6 Correct 6 ms 27224 KB Output is correct
7 Correct 6 ms 27096 KB Output is correct
8 Correct 6 ms 26972 KB Output is correct
9 Correct 6 ms 26972 KB Output is correct
10 Correct 6 ms 26972 KB Output is correct
11 Correct 10 ms 27228 KB Output is correct
12 Correct 10 ms 27228 KB Output is correct
13 Correct 11 ms 27276 KB Output is correct
14 Correct 14 ms 27224 KB Output is correct
15 Correct 14 ms 27304 KB Output is correct
16 Correct 21 ms 27224 KB Output is correct
17 Correct 18 ms 27248 KB Output is correct
18 Correct 21 ms 27236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3099 ms 41276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1993 ms 29932 KB Output is correct
2 Execution timed out 3041 ms 28860 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 26972 KB Output is correct
2 Correct 6 ms 26972 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 26972 KB Output is correct
5 Correct 8 ms 26972 KB Output is correct
6 Correct 6 ms 27224 KB Output is correct
7 Correct 6 ms 27096 KB Output is correct
8 Correct 6 ms 26972 KB Output is correct
9 Correct 6 ms 26972 KB Output is correct
10 Correct 6 ms 26972 KB Output is correct
11 Correct 10 ms 27228 KB Output is correct
12 Correct 10 ms 27228 KB Output is correct
13 Correct 11 ms 27276 KB Output is correct
14 Correct 14 ms 27224 KB Output is correct
15 Correct 14 ms 27304 KB Output is correct
16 Correct 21 ms 27224 KB Output is correct
17 Correct 18 ms 27248 KB Output is correct
18 Correct 21 ms 27236 KB Output is correct
19 Execution timed out 3029 ms 32008 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 26972 KB Output is correct
2 Correct 6 ms 26972 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 26972 KB Output is correct
5 Correct 8 ms 26972 KB Output is correct
6 Correct 6 ms 27224 KB Output is correct
7 Correct 6 ms 27096 KB Output is correct
8 Correct 6 ms 26972 KB Output is correct
9 Correct 6 ms 26972 KB Output is correct
10 Correct 6 ms 26972 KB Output is correct
11 Correct 10 ms 27228 KB Output is correct
12 Correct 10 ms 27228 KB Output is correct
13 Correct 11 ms 27276 KB Output is correct
14 Correct 14 ms 27224 KB Output is correct
15 Correct 14 ms 27304 KB Output is correct
16 Correct 21 ms 27224 KB Output is correct
17 Correct 18 ms 27248 KB Output is correct
18 Correct 21 ms 27236 KB Output is correct
19 Execution timed out 3099 ms 41276 KB Time limit exceeded
20 Halted 0 ms 0 KB -