Fading Coder

One Final Commit for the Last Sprint

Codeforces Round 882 Div. 2: Solutions for Problems A through E

Problem A: The Man who became a God For a sequence (a) of length (n), define the cost of a segment ([l, r]) as (f(l, r) = \sum_{i=l}^{r-1} |a_i - a_{i+1}|). We need to partition the entire sequence into (k) contiguous segments to maximize the sum of segment costs. The total cost of the whole sequenc...

Solution to AtCoder Beginner Contest 446

D - Max Straight This problem can be solved efficient using a hash map. Initially, I overcomplicated it by thinking about sorting and finding the longest increasing subsequence. However, a simple approach using a map workss perfectly. #include <bits/stdc++.h> using namespace std; int main() {...