Dynamic Programming Problem Collection and Solutions
Problem List
[AGC034E] Complete Compress
New Year and Original Order
[AGC024F] Simple Subsequence Problem
The Story of a Certain Songstress
[POI2015] MYJ
Periodni
[AGC026D] Histogram Coloring
[JOI Open 2016] Skyscraper
[USACO19DEC] Tree Depth P
[BZOJ3864] Hero Meet Devil
LOJ 6274 - Numbers
Yet Another Minimization Problem
[USACO19FEB] Mowing M ...
Posted on Tue, 04 Aug 2026 16:36:39 +0000 by zalath
Codeforces Round 165 Editorial - Problem Analysis
Problem A: Two Friends
There are two possible scenarios:
There exists a pair where person A's best friend is B, and B's best friend is A. In this case, just inviting these two individuals suffices.
No such mutual friendship exists. If person A's best friend is B, and B's best friend is C, then inviting A, B, and C ensures both A and B attend.
...
Posted on Sat, 01 Aug 2026 17:04:36 +0000 by penguinmasta
SMU Summer 2023 Contest Round 3 Solutions
A. Curriculum Vitae
The problem requires finding the longest subsequence where digit 1 is never followed by digit 0. This is equivalent to finding the longest non-decreasing subsequence in a binary sequence. An alternative approach uses prefix sums to count zeros and suffix sums to count ones.
#include <bits/stdc++.h>
#define endl '\n'
# ...
Posted on Tue, 30 Jun 2026 18:04:49 +0000 by daz1034
Solutions for AtCoder Beginner Contest 052 Problems in C++
A – Two Rectangles [Max Area Logic]
Given the dimensions of two rectangles:
Rectangle 1: (A \times B)
Rectangle 2: (C \times D)
Determine and output the larger area. Tie-breaking is irrelevant.
i64 a, b, c, d;
std::cin >> a >> b >> c >> d;
i64 r1 = a * b, r2 = c * d;
i64 best = (r1 >= r2) ? r1 : r2;
std::cout <&l ...
Posted on Sun, 28 Jun 2026 17:59:34 +0000 by Angus
CCPC Qinhuangdao Contest: Problem Solutions and Code
Problem A. Is Your School the Kingdom of Construction I
Approach
The official solution provides a clear construction method. We need to generate exactly k coordinate pairs (x, y) where both coordinates are between 1 and n.
First, we construct a base set of edges forming a connected structure. Then, if additional pairs are needed, we fill in the ...
Posted on Sun, 10 May 2026 20:13:05 +0000 by ragefu