Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
|---|---|---|---|---|---|---|
| 2178 | Good Bye 2025 | FINISHED | False | 10800 | 9559523 | Dec. 27, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 306 ) | H | Create or Duplicate | PROGRAMMING | number theory shortest paths |
Santa realized that hand-drawing circles takes too long, so he has turned to magic to meet his production quotas. There are three types of presents with distinct values (a), (b), and (c). Initially, Santa has exactly one present of each type. You are given two integers (m) and (k), representing Santa's favorite number and the cost of duplication, respectively. Santa can cast the following two types of spells any number of times (possibly zero): Create — Choose a type of present and create one additional present of that type. This spell costs (x) mana, where (x\in \{a,b,c\}) is the value of the chosen type. Duplicate — Choose a type of present and duplicate all presents of that type. This spell costs (k) mana. Santa wants to perform a sequence of spells such that the sum of the values of all presents is a multiple of (m) after the spells. Determine the minimum amount of mana Santa needs to achieve this. It can be shown that, under the given constraints, such a sequence of spells always exists. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The only line of each test case contains five integers (a), (b), (c), (m), and (k) ((1\leq a< b< c< m\leq 5\cdot 10^5), (1\leq k\leq 5\cdot 10^5)). It is guaranteed that the sum of (m) over all test cases does not exceed (5\cdot 10^5). It is guaranteed that the sum of (k) over all test cases does not exceed (5\cdot 10^5). For each test case, output a single integer — the minimum amount of mana Santa needs to make the sum of the values of all presents a multiple of (m). Let (\ell) be the list of values of presents and (\operatorname{sum}(\ell)) be the sum of all elements in (\ell). In the first test case, below is an optimal sequence of operations: In the second test case, it is optimal to not perform any operat |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 355429333 | JaeminPark | H | Dec. 28, 2025, 12:57 a.m. | OK | C++17 (GCC 7-32) | TESTS | 71 | 1593 | 129024000 | ||
| 355437497 | CCCCOrz | H | Dec. 28, 2025, 3:57 a.m. | OK | C++17 (GCC 7-32) | TESTS | 71 | 1968 | 144998400 | ||
| 355431547 | Mescherez | H | Dec. 28, 2025, 1:53 a.m. | OK | C++17 (GCC 7-32) | TESTS | 71 | 2031 | 129024000 | ||
| 355427692 | Potassium | H | Dec. 27, 2025, 11:56 p.m. | OK | C++17 (GCC 7-32) | TESTS | 71 | 2062 | 53350400 | ||
| 355418840 | BananaKatana | H | Dec. 27, 2025, 8:33 p.m. | OK | C++17 (GCC 7-32) | TESTS | 71 | 2296 | 129024000 | ||
| 355427379 | Potassium | H | Dec. 27, 2025, 11:45 p.m. | OK | C++17 (GCC 7-32) | TESTS | 71 | 2359 | 131072000 | ||
| 355437433 | keisuke6 | H | Dec. 28, 2025, 3:56 a.m. | OK | C++17 (GCC 7-32) | TESTS | 71 | 2640 | 179507200 | ||
| 355438597 | linyue | H | Dec. 28, 2025, 4:17 a.m. | OK | C++17 (GCC 7-32) | TESTS | 71 | 4078 | 509132800 | ||
| 355399008 | potato167 | H | Dec. 27, 2025, 5:08 p.m. | OK | C++17 (GCC 7-32) | TESTS | 70 | 4359 | 143974400 | ||
| 355404417 | JDScript0117 | H | Dec. 27, 2025, 5:24 p.m. | OK | C++20 (GCC 13-64) | TESTS | 70 | 562 | 50278400 | ||
| 355406170 | jeroenodb | H | Dec. 27, 2025, 5:29 p.m. | OK | C++20 (GCC 13-64) | TESTS | 70 | 1140 | 9523200 | ||
| 355433346 | qiuzx | H | Dec. 28, 2025, 2:33 a.m. | OK | C++20 (GCC 13-64) | TESTS | 71 | 1593 | 130048000 | ||
| 355419503 | 244mhq | H | Dec. 27, 2025, 8:42 p.m. | OK | C++20 (GCC 13-64) | TESTS | 71 | 1718 | 130150400 | ||
| 355436087 | operator_ | H | Dec. 28, 2025, 3:31 a.m. | OK | C++20 (GCC 13-64) | TESTS | 71 | 2296 | 181043200 | ||
| 355429884 | Chenly | H | Dec. 28, 2025, 1:10 a.m. | OK | C++20 (GCC 13-64) | TESTS | 71 | 2515 | 181145600 | ||
| 355394374 | kotatsugame | H | Dec. 27, 2025, 4:54 p.m. | OK | C++20 (GCC 13-64) | TESTS | 70 | 2671 | 34406400 | ||
| 355435964 | jenil0108 | H | Dec. 28, 2025, 3:29 a.m. | OK | C++20 (GCC 13-64) | TESTS | 71 | 3125 | 241356800 | ||
| 355418389 | sai-17 | H | Dec. 27, 2025, 8:29 p.m. | OK | C++20 (GCC 13-64) | TESTS | 71 | 3234 | 431718400 | ||
| 355437962 | LMydd0225 | H | Dec. 28, 2025, 4:05 a.m. | OK | C++20 (GCC 13-64) | TESTS | 71 | 3312 | 591360000 |
Back to search problems