I wants to do this question with segment tree
i know i can change element in logn time but how i can check there at least on segment available or not according to the que
que link link
plz help
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | adamant | 157 |
6 | awoo | 157 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | djm03178 | 153 |
I wants to do this question with segment tree
i know i can change element in logn time but how i can check there at least on segment available or not according to the que
que link link
plz help
Name |
---|
In the contest, I tried implementing the Segment tree and thought the prefix array won't pass the time constraints, but I was wrong, here is my segment tree AC solution although it can be further optimized.
https://codeforces.me/contest/1843/submission/210506220
Also I didn't quite get wym by " check there at least on segment available " ??
thanks man got it :)
you don't need segment trees for this... its just a basic binary search
Why learning segment trees when you haven't even solved 1300-Rated problems ?
Yeah, In last maybe 20 rounds i dont see a problem(with rating <= 2000), which have solution like "segment tree" or simething more harder. But learning it when you are 1000...
If you're curious, this is a working solution with binary search and prefix sums — no segtree needed, and takes only ~60ms and 1.5MB: 210537397
Why do you learn Segment Tree? Go learn Binary Search.
In fact Binary Search was the expected solution, stop overcomplicating your solutions using hard algorirthms.
If you are interested in the range update method of solving the problem but you need an easy way to do this, I recommend the square root algorithm. It's more suited for beginners, and it is what I used in the contest.