Alternative O(n log n) Fenwick Tree Solution for Problem F (It Just Keeps Going Sideways)

Revision en1, by sofyanalam, 2026-05-21 17:19:59

Accepted Code375452836

Recently I solved this problem using a different observation from the official editorial, so I thought I'd share it.

Observation 1: Computing Total Movement
Observation 2: Which Height Should We Decrease?
Computing greater(i) Efficiently
Complexity Analysis
Final Notes
Tags data structures, greedy, fenwick tree, implementations, codeforces

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English sofyanalam 2026-05-21 17:19:59 3873 Initial revision (published)