Given an array of digits (values are from 0 to 9), find the minimum possible sum of two numbers formed from digits of the array. All digits… Read more “Minimum sum of two numbers formed from digits of an array”
Sort an array of 0s, 1s and 2s
Given an array A consisting 0s, 1s and 2s, write a function that sorts A. The functions should put all 0s first, then all 1s and all… Read more “Sort an array of 0s, 1s and 2s”
Minimum cost path
Given a cost matrix cost[][] and a position (m, n) in cost[][], write a function that returns cost of minimum cost path to reach (m, n) from… Read more “Minimum cost path”
Codeforces 3A
The king is left alone on the chessboard. In spite of this loneliness, he doesn’t lose heart, because he has business of national importance. For example, he… Read more “Codeforces 3A”
Codeforces 1B
In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B,… Read more “Codeforces 1B”
Codeforces 1A
Theatre Square in the capital city of Berland has a rectangular shape with the size n × mmeters. On the occasion of the city’s anniversary, a decision was taken to… Read more “Codeforces 1A”
Codeforces 2A
The winner of the card game popular in Berland “Berlogging” is determined according to the following rules. If at the end of the game there is only… Read more “Codeforces 2A”
Grass Planting USACO Silver Jan. 2019 #1
It’s the time of year for Farmer John to plant grass in all of his fields. The entire farm consists of N fields (1≤N≤10^5), conveniently numbered 1…N and conveniently connected by N−1N−1 bidirectional… Read more “Grass Planting USACO Silver Jan. 2019 #1”
High Card Low Card (USACO 2015 December gold)
Bessie the cow is a huge fan of card games, which is quite surprising, given her lack of opposable thumbs. Unfortunately, none of the other cows in… Read more “High Card Low Card (USACO 2015 December gold)”