Solving CEOI2018 Cloud Computing with Optimized 0-1 Knapsack
The problem involves selecting a subset of computers and fulfilling orders to maximize profit, under constraints on core count and clock frequency.
Each computer provides a certain number of cores at a cost and has a minimum required clock frequency. Each order yields revenue but requires a specific number of cores and can only be processed on ...
Posted on Thu, 20 Aug 2026 16:31:17 +0000 by newbiez
Competitive Programming Contest Solutions and Analysis
Calculating Paths in Dynamic Graphs
To determine the total number of simple paths in a Directed Acyclic Graph (DAG), we analyze the in-degrees and out-degrees. Let $fwd_dp[i]$ be the number of paths ending at node $i$. This can be computed using topological sorting. The total number of paths in the original graph is $\sum fwd_dp[i]$ for all nod ...
Posted on Wed, 19 Aug 2026 16:43:01 +0000 by Niccaman
ABC311 Contest Solutions
A - First ABC
Solution
We can track the first appearence of each character using boolean flags. By iterating through the string, we can determine the earliest position where all three required characters have been encountered.
#include <iostream>
#include <string>
using namespace std;
int main() {
int length;
string input;
...
Posted on Tue, 18 Aug 2026 16:36:57 +0000 by sysop
Interval DP Solution for String Coloring Problem
Problem Overview
This problem can be solved efficiently using interval dynamic programming. Given a string, the goal is to determine the minimum number of operations required to paint the entire string, where each operation can paint any contiguous segment.
Dynamic Programming Formulation
Define dp[l][r] as the minimum number of steps needed to ...
Posted on Sat, 15 Aug 2026 16:30:55 +0000 by Rushyo
Comprehensive Problem Solutions from Paken Camp Contests
2023 Edition
Day 1
G. Constructing an MST with Product Weights (Easy)
We are given a sequence (a) (with (|a_i| \le 10^6)), and we must build an undirected graph on (n) vertices ((n \le 2\cdot 10^5)) where the weight of edge ((i,j)) equals (a_i a_j). The goal is to compute the weight of the minimum spanning tree.
First, sort (a); this has no eff ...
Posted on Fri, 14 Aug 2026 16:32:06 +0000 by Chinese
Understanding Greedy Algorithms: Principles and Applications
Greedy algorithms represent a straightforward approach to problem-solving where, at each stage, the algorithm makes a locally optimal choice with the expectation that this choice will lead to a globally optimal solution. This strategy is particularly effective for problems exhibiting optimal substructure. However, it's crucial to recognize that ...
Posted on Tue, 11 Aug 2026 16:41:48 +0000 by lances
Programming Competition: Problem Analysis and Solutions
Competition Details
Duration: 3 hours
Start Time: 2026/1/30 8:00
End Time: 2026/1/30 11:00
Difficulty Level: High
Final Score: 340
Lost Points: 60
Problem Set
Problem 1: Element Removal Sum
Description
Given a sequence of integers A of length N and an integer M, determine if it's possible to remove exactly one element from A such that the ...
Posted on Tue, 11 Aug 2026 16:13:55 +0000 by devangel
Binary Search for Rotated Arrays, Arrow Balloons, and Palindrome Partitioning
153. Minimum in Rotated Sorted Array
Approach
A rotated sorted array is formed by shifting elements from the end to the beginning. For instance, rotating [0,1,2,4,5,6,7] four times yields [4,5,6,7,0,1,2]. To find the minimum element efficiently, use binary search. Compare the middle element with the rightmost element:
If arr[mid] < arr[righ ...
Posted on Wed, 05 Aug 2026 16:35:41 +0000 by fuzzy1
Competitive Programming Solutions: Niuke Summer Multi-School Training Camp 2024
Given an integer x, construct a y < x such that gcd(x, y) = x ⊕ y (bitwise XOR).
The solution is to take y = x - lowestSetBit(x). If x is a power of 2, then no solution exists.
#include<iostream>
#include<cmath>
using namespace std;
using ll = long long;
void solve() {
ll x;
cin >> x;
ll lowest_bit = x & ...
Posted on Tue, 04 Aug 2026 16:19:06 +0000 by VLE79E
Applying Expected Value in Algorithm Design
Expected value is a fundamental concept in probability theory and statistics, used to describe the average or central tendency of data. In computer algorithm competitions, expected value algorithms are considered medium to advanced level, playing a crucial role in programming. In recent years, problems involving expectations and expectation dyn ...
Posted on Sat, 01 Aug 2026 16:42:30 +0000 by zak