---
id: seg-ext
title: "More Applications of Segment Tree"
author: Benjamin Qi
prerequisites:
- Gold - Static Range Queries
- Gold - Point Update Range Query
description: "?"
frequency: 3
---
import { Problem } from "../models";
export const metadata = {
problems: {
walkSam: [
new Problem("CSES", "Hotel Queries", "1143", "Easy", false, ["PURQ"], "walk"),
],
walk: [
new Problem("Old Gold", "Seating", "231", "Normal", false, [], "walk on max segtree"),
new Problem("Plat", "Balancing", "624", "Normal", false, [], "walk"),
],
combSam: [
new Problem("CSES", "Subarray Sum Queries", "1190", "Normal", false, ["PURQ"], "comb"),
],
comb: [
new Problem("Plat", "High Card Low Card", "577", "Normal", false, ["PURQ", "Greedy"], "comb"),
new Problem("POI", "Cards", "https://szkopul.edu.pl/problemset/problem/qpsk3ygf8MU7D_1Es0oc_xd8/site/?key=statement", "Normal", false, [], "comb"),
new Problem("Old Gold", "Marathon", "495", "Normal", false, [], "comb"),
new Problem("Old Gold", "Optimal Milking", "365", "Normal", false, [], "comb"),
],
waveletSam: [
new Problem("YS", "Range K-th Smallest", "range_kth_smallest", "Hard", false, ["Wavelet"], ""),
],
wavelet: [
new Problem("Kattis", "Easy Query", "easyquery", "Hard", false, ["Wavelet"], ""),
new Problem("DMOJ", "Ninjaclasher's Wrath 2", "globexcup19s4", "Hard", false, ["Wavelet"], ""),
],
}
};
## Walking on a Segment Tree
You want to support queries of the following form on an array $a_1,\ldots,a_N$ (along with point updates).
> Find the first $i$ such that $a_i\ge x$.
Of course, you can do this in $O(\log^2N)$ time with a max segment tree and binary searching on the first $i$ such that $\max(a_1,\ldots,a_i)\ge x$. But try to do this in $O(\log N)$ time.
## Combining
(solution to above problem)
## Wavelet Tree
### Tutorial
### Problems