답안 #816883

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
816883 2023-08-09T07:13:43 Z acatmeowmeow Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++11
13 / 100
1580 ms 92168 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long 

const int N = 1e6;
int n, m, arr[N + 5];

struct info {
	int res = 0, mx = 0, mn = 1e18;
	info operator+(info x) {
		info ans;
		ans.res = max({res, x.res, mx > x.mn ? mx + x.mn : 0});
		ans.mx = max(mx, x.mx);
		ans.mn = min(mn, x.mn);
		return ans;
	}
};

info tree[4*N + 5];

void update(int v, int tl, int tr, int k, int x) {
	if (tl == tr) tree[v].mx = tree[v].mn = x;
	else {
		int tm = (tl + tr)/2;
		if (k <= tm) update(v*2, tl, tm, k, x);
		else update(v*2 + 1, tm + 1, tr, k, x);
		tree[v] = tree[v*2] + tree[v*2 + 1];
	}
}

info query(int v, int tl, int tr, int l, int r) {
	if (l > r) {
		info ans;
		return ans;
	} else if (tl == l && tr == r) {
		return tree[v];
	} else {
		int tm = (tl + tr)/2;
		return query(v*2, tl, tm, l, min(tm, r)) + query(v*2 + 1, tm + 1, tr, max(l, tm + 1), r);
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		update(1, 1, n, i, arr[i]);
	}
	for (int i = 1; i <= m; i++) {
		int l, r, k;
		cin >> l >> r >> k;
		info res = query(1, 1, n, l, r);
		if (res.res <= k) cout << 1 << '\n';
		else cout << 0 << '\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1410 ms 59316 KB Output is correct
2 Correct 1580 ms 92160 KB Output is correct
3 Correct 1448 ms 92012 KB Output is correct
4 Correct 1399 ms 92168 KB Output is correct
5 Correct 1459 ms 92160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 134 ms 7396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -