# PSHTRG - Editorial

**URL:** <https://discuss.codechef.com/t/pshtrg-editorial/18196>\
**Category:** editorial\
**Tags:** editorial, march18, medium, pshtrg, segment-tree, sorting, triangle\
**Created:** [March 5, 2018, 6:21pm UTC](https://discuss.codechef.com/t/pshtrg-editorial/18196 "2018-03-05T18:21:39Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![droy0528](https://discuss.codechef.com/user_avatar/discuss.codechef.com/droy0528/32/1387_2.png) [@droy0528](https://discuss.codechef.com/u/droy0528)\
**Post date:** [March 12, 2018, 6:07pm UTC](https://discuss.codechef.com/t/pshtrg-editorial/18196/22 "2018-03-12T18:07:36Z")

</div>

very nice editorial @adkroxx

---

<div class="post-metadata">

**Author:** ![sdssudhu](https://discuss.codechef.com/user_avatar/discuss.codechef.com/sdssudhu/32/57466_2.png) [@sdssudhu](https://discuss.codechef.com/u/sdssudhu)\
**Post date:** [March 12, 2018, 8:18pm UTC](https://discuss.codechef.com/t/pshtrg-editorial/18196/23 "2018-03-12T20:18:28Z")

</div>

Wow such a different idea . Never thought of this.

---

<div class="post-metadata">

**Author:** ![kailashnath199](https://discuss.codechef.com/user_avatar/discuss.codechef.com/kailashnath199/32/12967_2.png) [@kailashnath199](https://discuss.codechef.com/u/kailashnath199)\
**Post date:** [March 12, 2018, 9:40pm UTC](https://discuss.codechef.com/t/pshtrg-editorial/18196/24 "2018-03-12T21:40:47Z")

</div>

> **[Algorithm Gym :: Everything About Segment Trees - Codeforces](https://codeforces.com/blog/entry/15890)**
>
> Codeforces. Programming competitions and contests, programming community

---

<div class="post-metadata">

**Author:** ![adkroxx](https://discuss.codechef.com/user_avatar/discuss.codechef.com/adkroxx/32/9164_2.png) [@adkroxx](https://discuss.codechef.com/u/adkroxx)\
**Post date:** [March 12, 2018, 11:26pm UTC](https://discuss.codechef.com/t/pshtrg-editorial/18196/25 "2018-03-12T23:26:14Z")

</div>

I knew about this solution too. But for me something else was simpler, hence I decided to describe that solution. But anyway good job. 🙂

---

<div class="post-metadata">

**Author:** ![namanjain007](https://discuss.codechef.com/user_avatar/discuss.codechef.com/namanjain007/32/22910_2.png) [@namanjain007](https://discuss.codechef.com/u/namanjain007)\
**Post date:** [March 13, 2018, 4:31pm UTC](https://discuss.codechef.com/t/pshtrg-editorial/18196/26 "2018-03-13T16:31:41Z")

</div>

Editorial just correctly explained that if there are more than 50 nos in the range l to r then as if a plus b is less than c for all (c\>b\>a) then c should be greater than Fibonacci nos series having elements a b c etc. So c would exceed your upper limit

---

<div class="post-metadata">

**Author:** ![shawnbam\_96](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@shawnbam\_96](https://discuss.codechef.com/u/shawnbam_96)\
**Post date:** [March 14, 2018, 5:05am UTC](https://discuss.codechef.com/t/pshtrg-editorial/18196/27 "2018-03-14T05:05:24Z")

</div>

The only reason I can think of -

Weak test cases (lengths of required(valid) triangle were very close to r) i.e. **number of queries giving required triangle in less number of iterations \>\> number of queries giving required triangle in more number of iterations**

---

<div class="post-metadata">

**Author:** ![ista2000](https://discuss.codechef.com/user_avatar/discuss.codechef.com/ista2000/32/85671_2.png) [@ista2000](https://discuss.codechef.com/u/ista2000)\
**Post date:** [March 14, 2018, 10:30pm UTC](https://discuss.codechef.com/t/pshtrg-editorial/18196/28 "2018-03-14T22:30:01Z")

</div>

Ah, yes the intended solution uses something different too. Its a cross between a segtree and a merge sort tree. Thanks for describing the intended one. 😃

---

<div class="post-metadata">

**Author:** ![aryanc403](https://discuss.codechef.com/user_avatar/discuss.codechef.com/aryanc403/32/215126_2.png) [@aryanc403](https://discuss.codechef.com/u/aryanc403)\
**Post date:** [March 14, 2018, 10:35pm UTC](https://discuss.codechef.com/t/pshtrg-editorial/18196/29 "2018-03-14T22:35:19Z")

</div>

[https://www.codechef.com/viewsolution/17834749](https://www.codechef.com/viewsolution/17834749)  
@kailashnath199 Thank you Man. Now, i am able to do this question using segment tree.  
Thank You.

[Previous page](https://discuss.codechef.com/t/pshtrg-editorial/18196.md?page=1)
