#greedy
CF 2222B - Artistic Balance Tree
CF 2222B - Artistic Balance Tree Rating: - Tags: greedy, sortings Solve time: 3m 53s Verified: no Solution Problem Understanding We have an array, and before each marking operation we are allowed to reverse any odd-length segment centered at some position. After that reversal, the element currently sitting at index x_i becomes marked. The subtle detail is that marks belong to elements, not positions. If an element gets marked and...
CF 1949B - Charming Meals
CF 1949B - Charming Meals Rating: 1500 Tags: binary search, brute force, greedy, sortings Solve time: 1m 44s Verified: yes Solution Problem Understanding We have two arrays of size n . The array a contains the spiciness values of the appetizers, and the array b contains the spiciness values of the main dishes. Every appetizer must be paired with exactly one main dish, and every main dish must be used...
CF 1949G - Scooter
CF 1949G - Scooter Rating: 2300 Tags: graphs, greedy Solve time: 3m 15s Verified: no Solution Problem Understanding Each building has two independent pieces of information. The first string describes what class is held there. A building may need a mathematics professor, a computer science professor, or no professor at all. The second string describes which professor is initially located there. A building may contain a mathematics professor, a computer...
CF 1949H - Division Avoidance
CF 1949H - Division Avoidance Rating: 3100 Tags: greedy, math Solve time: 5m 53s Verified: no Solution Problem Understanding The process starts with a single cell at (0, 0) . Whenever we divide a cell (x, y) , that cell disappears and produces (x + 1, y) and (x, y + 1) . A division is only legal if neither child is currently present. We are given a finite set...
CF 1949F - Dating
CF 1949F - Dating Rating: 2200 Tags: greedy, sortings, trees Solve time: 1m 57s Verified: no Solution Problem Understanding Each user can be viewed as a set of activities. We need to find two users whose sets satisfy three conditions simultaneously: They share at least one activity. The first user has at least one activity that the second user does not have. The second user has at least one activity...
CF 1949C - Annual Ants' Gathering
CF 1949C - Annual Ants' Gathering Rating: 1900 Tags: dfs and similar, dp, greedy, trees Solve time: 4m 48s Verified: yes Solution Problem Understanding Each vertex of the tree initially contains exactly one ant. A move chooses an edge $(u,v)$ and orders all ants currently gathered at $u$ to move to $v$. The ants obey only when the destination already contains at least as many ants as the source. If...
CF 241A - Old Peykan
CF 241A - Old Peykan Rating: 1300 Tags: greedy Solve time: 1m 12s Verified: yes Solution Problem Understanding We are asked to model a journey along a straight line of cities connected by one-way roads, where a car travels at a constant speed of one kilometer per hour and consumes one liter of fuel per kilometer. Each city (except the last) has a fuel supply that replenishes every k hours....
CF 48D - Permutations
CF 48D - Permutations Rating: 1500 Tags: greedy Solve time: 2m 3s Verified: no Solution Problem Understanding We are given a shuffled array that originally came from concatenating several permutations. Each permutation may have a different size. After concatenation, all numbers were mixed together, so the original grouping disappeared. Our task is to assign every array element to some permutation so that each group forms a valid permutation. A valid...
CF 48F - Snow sellers
CF 48F - Snow sellers Rating: 2800 Tags: greedy, sortings Solve time: 1m 27s Verified: yes Solution Problem Understanding We are asked to plan snow purchases over n days from m companies, ensuring we buy exactly W cubic meters each day. Each company produces a fixed daily amount w[i] , but the cost of all snow from that company decreases linearly: c[i] on day 1, c[i] - a[i] on day...