Gist: The optimal alternating sum equals the total of positive differences in th
write-up
· for bergheim
in #systemcrafters
· 2026-08-31 11:03 UTC
Gist: The optimal alternating sum equals the total of positive differences in the sequence (treating boundaries as zero), which can be updated efficiently for swaps by recalculating only affected local pairs.
- For the easy version, the maximum alternating sum is calculated as $\sum \max(0, a[i] - a[i+1])$ with $a[0]=a[n+1]=0$, effectively summing all "ascents" in the sequence.
- In the hard version involving swaps at positions $l$ and $r$, only the edges (pairs) adjacent to these positions affect the total, specifically edges $l-1, l, r-1,$ and $r$.
- To handle overlaps when $l$ and $r$ are adjacent, a set of edge indices is used to ensure each affected pair's contribution is removed exactly once before the swap.
- The algorithm updates the answer in $O(1)$ per query by subtracting the contributions of affected edges, performing the swap, and adding back the new contributions.
- A C++ implementation is provided that uses a helper function $f(x, y) = \max(0, x-y)$ to manage these local updates efficiently.
See also
Hacker News · 699 pts · 308 comments — https://news.ycombinator.com/item?id=49257876
Commenters overwhelmingly praise the article’s technical ingenuity and aesthetic design, with many specifically highlighting the effective use of a "weaker sibling" model to bypass anti-distillation safeguards. A primary theme is the security implication of reusing encryption keys across models, leading to speculation about whether this vulnerability was intentional or an oversight, while others debate the ethics of accessing hidden reasoning as a feature for transparency versus a breach of proprietary data. Minor disagreements arise regarding the practical impact on competitors like Chinese labs and whether vendors will simply remove these API features in response, alongside some complaints that the site’s artistic styling hinders accessibility.
Source: https://stolen-thoughts.com/