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.
Problems
Monocarp is gathering an army to fight a dragon in a videogame. The army consists of two parts: the heroes and the defensive artifacts. Each hero has one parameter — his health. Each defensive artifact also has one parameter — its durability. Before the battle begins, Monocarp distributes artifacts to the heroes so that each hero receives at most one artifact. The battle consists of rounds that proceed as follows: first, the dragon deals damage equal to (\frac{1}{a + b}) ( a real number without rounding ) to each hero, where (a) is the number of heroes alive and (b) is the number of active artifacts; after that, all heroes with health (0) or less die; finally, some artifacts are deactivated. An artifact with durability (x) is deactivated when one of the following occurs: the hero holding the artifact either dies or receives (x) total damage (from the start of the battle). If an artifact is not held by any hero, it is inactive from the beginning of the battle. The battle ends when there are no heroes left alive. Initially, the army is empty. There are (q) queries: add a hero with health (x) or an artifact with durability (y) to the army. After each query, determine the maximum number of rounds that Monocarp can survive if he distributes the artifacts optimally. The first line contains one integer (q) ((1 \le q \le 3 \cdot 10^5)) — the number of queries. In the (i)-th of the following (q) lines, there are two integers (t_i) and (v_i) ((t_i \in \{1, 2\}); (1 \le v_i \le 10^9)) — the type of the query and the value of the query parameter. If the type is (1), a hero with health (v_i) is added. If the type is (2), an artifact with durability (v_i) is added. Print (q) integers. After each query, output the maximum number of rounds that Monocarp can survive if he distributes the artifacts optimally. Let's consider the first example. An artifact with durability (5) is added. |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
285933910 |
hatuankhanh05 |
G |
Oct. 14, 2024, 4:57 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
54 |
3406 |
19353600 |
|
|
|
285951844 |
Olzhasiek |
G |
Oct. 14, 2024, 7:06 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
1108 |
20275200 |
|
|
|
285988370 |
tarjen |
G |
Oct. 15, 2024, 5:09 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
1312 |
40345600 |
|
|
|
285973754 |
Tx_Lcy |
G |
Oct. 15, 2024, 1:38 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
1484 |
27852800 |
|
|
|
285927201 |
abc864197532 |
G |
Oct. 14, 2024, 4:32 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
1546 |
11059200 |
|
|
|
285937563 |
tracktor |
G |
Oct. 14, 2024, 5:18 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
1593 |
20992000 |
|
|
|
285927378 |
abc864197532 |
G |
Oct. 14, 2024, 4:32 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
1702 |
9625600 |
|
|
|
285926718 |
abc864197532 |
G |
Oct. 14, 2024, 4:31 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
1734 |
11366400 |
|
|
|
285968149 |
Ormlis |
G |
Oct. 14, 2024, 11:16 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
1749 |
21708800 |
|
|
|
285927290 |
abc864197532 |
G |
Oct. 14, 2024, 4:32 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
1796 |
16384000 |
|
|
|
285968156 |
Ormlis |
G |
Oct. 14, 2024, 11:16 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
1811 |
21708800 |
|
|
|
285930826 |
neal |
G |
Oct. 14, 2024, 4:42 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
54 |
1296 |
10649600 |
|
|
|
285929850 |
neal |
G |
Oct. 14, 2024, 4:38 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
54 |
1359 |
7065600 |
|
|
|
285925790 |
neal |
G |
Oct. 14, 2024, 4:29 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
54 |
1827 |
8396800 |
|
|
|
285974967 |
PhoenixRebirth |
G |
Oct. 15, 2024, 2:03 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
54 |
2421 |
19251200 |
|
|
|
285933260 |
chinerist |
G |
Oct. 14, 2024, 4:54 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
54 |
3139 |
34611200 |
|
|
remove filters
Back to search problems