답안 #964898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964898 2024-04-17T17:06:38 Z Acanikolic Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
17 / 100
3000 ms 45068 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;
		bool ok = true;
		for(int i = l; i <= r; i++) {
			int prv = prev[i];
			if(prv >= l) {
				if(a[prv] + a[i] > k) ok = false;
			}
		}
		cout << ok << "\n";
	}
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 26972 KB Output is correct
2 Correct 7 ms 27144 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 26972 KB Output is correct
5 Correct 6 ms 26972 KB Output is correct
6 Correct 8 ms 26972 KB Output is correct
7 Correct 7 ms 26972 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 27068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 26972 KB Output is correct
2 Correct 7 ms 27144 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 26972 KB Output is correct
5 Correct 6 ms 26972 KB Output is correct
6 Correct 8 ms 26972 KB Output is correct
7 Correct 7 ms 26972 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 27068 KB Output is correct
11 Correct 10 ms 27228 KB Output is correct
12 Correct 13 ms 27224 KB Output is correct
13 Correct 13 ms 27264 KB Output is correct
14 Correct 15 ms 27336 KB Output is correct
15 Correct 15 ms 27244 KB Output is correct
16 Correct 19 ms 27224 KB Output is correct
17 Correct 25 ms 27272 KB Output is correct
18 Correct 20 ms 27228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3014 ms 45068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2247 ms 29892 KB Output is correct
2 Execution timed out 3043 ms 29128 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 26972 KB Output is correct
2 Correct 7 ms 27144 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 26972 KB Output is correct
5 Correct 6 ms 26972 KB Output is correct
6 Correct 8 ms 26972 KB Output is correct
7 Correct 7 ms 26972 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 27068 KB Output is correct
11 Correct 10 ms 27228 KB Output is correct
12 Correct 13 ms 27224 KB Output is correct
13 Correct 13 ms 27264 KB Output is correct
14 Correct 15 ms 27336 KB Output is correct
15 Correct 15 ms 27244 KB Output is correct
16 Correct 19 ms 27224 KB Output is correct
17 Correct 25 ms 27272 KB Output is correct
18 Correct 20 ms 27228 KB Output is correct
19 Execution timed out 3027 ms 32332 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 26972 KB Output is correct
2 Correct 7 ms 27144 KB Output is correct
3 Correct 6 ms 26972 KB Output is correct
4 Correct 6 ms 26972 KB Output is correct
5 Correct 6 ms 26972 KB Output is correct
6 Correct 8 ms 26972 KB Output is correct
7 Correct 7 ms 26972 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 27068 KB Output is correct
11 Correct 10 ms 27228 KB Output is correct
12 Correct 13 ms 27224 KB Output is correct
13 Correct 13 ms 27264 KB Output is correct
14 Correct 15 ms 27336 KB Output is correct
15 Correct 15 ms 27244 KB Output is correct
16 Correct 19 ms 27224 KB Output is correct
17 Correct 25 ms 27272 KB Output is correct
18 Correct 20 ms 27228 KB Output is correct
19 Execution timed out 3014 ms 45068 KB Time limit exceeded
20 Halted 0 ms 0 KB -