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 |
---|---|---|---|---|---|---|
1578 | ICPC WF Moscow Invitational Contest - Online Mirror (Unrated, ICPC Rules, Teams Preferred) | FINISHED | False | 18000 | 104172863 | Oct. 1, 2021, 1:05 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 240 ) | J | Just Kingdom | PROGRAMMING | data structures dfs and similar |
B"The Just Kingdom is ruled by a king and his n lords, numbered 1 to n . Each of the lords is a vassal of some overlord, who might be the king himself, or a different lord closer to the king. The king, and all his lords, are just and kind. Each lord has certain needs, which can be expressed as a certain amount of money they need. However, if a lord, or the king, receives any money, they will first split it equally between all their vassals who still have unmet needs. Only if all the needs of all their vassals are met, they will take the money to fulfill their own needs. If there is any money left over, they will return the excess to their overlord (who follows the standard procedure for distributing money). At the beginning of the year, the king receives a certain sum of tax money and proceeds to split it according to the rules above. If the amount of tax money is greater than the total needs of all the lords, the procedure guarantees everybody's needs will be fulfilled, and the excess money will be left with the king. However, if there is not enough money, some lords will not have their needs met. For each lord, determine the minimum amount of tax money the king has to receive so that this lord's needs are met. The first line of the input contains the number of lords n ( 0 <= n <= 3 cdot 10^5 ). Each of the next n lines describes one of the lords. The i -th line contains two integers: o_i ( 0 <= o_i < i ) -- the index of the overlord of the i -th lord (with zero meaning the king is the overlord), and m_i ( 1 <= m_i <= 10^6 ) -- the amount of money the i -th lord needs. Print n integer numbers t_i . The i -th number should be the minimum integer amount of tax money the king has to receive for which the needs of the i -th lord will be met. In the sample input, if the king receives 5 units of tax money, he will split it equally between his vassals -- the "... |
Tutorial (PDF) |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
130498290 | eecs | J | Oct. 1, 2021, 6:43 p.m. | OK | GNU C++14 | TESTS | 36 | 826 | 133734400 | ||
130486731 | maojiayi wangziji AcFunction | J | Oct. 1, 2021, 4:39 p.m. | OK | GNU C++14 | TESTS | 36 | 904 | 127590400 | ||
130476435 | tzc_wk gig_lf Alex_Wei | J | Oct. 1, 2021, 2:53 p.m. | OK | GNU C++14 | TESTS | 36 | 2932 | 337817600 | ||
130493912 | Maksim1744 never_giveup | J | Oct. 1, 2021, 5:53 p.m. | OK | GNU C++17 | TESTS | 36 | 717 | 558694400 | ||
130493676 | Maksim1744 never_giveup | J | Oct. 1, 2021, 5:51 p.m. | OK | GNU C++17 | TESTS | 36 | 1091 | 558694400 | ||
130488623 | Pyqe | J | Oct. 1, 2021, 5:01 p.m. | OK | GNU C++17 | TESTS | 36 | 4320 | 614297600 | ||
130491311 | yosupo | J | Oct. 1, 2021, 5:27 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 795 | 204800000 | ||
130472536 | snuke hos.lyric maroonrk | J | Oct. 1, 2021, 2:19 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 842 | 157798400 | ||
130494610 | Fulisike Miracle03 Retired_MiFaFaOvO | J | Oct. 1, 2021, 6 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 857 | 159436800 | ||
130480791 | tlwpdus ainta molamola. | J | Oct. 1, 2021, 3:37 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 1076 | 333824000 | ||
130485823 | Argentina medium_waxberry Misaka-Mikoto- | J | Oct. 1, 2021, 4:30 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 1185 | 50176000 | ||
130493047 | szb KagamineRin SSerxhs | J | Oct. 1, 2021, 5:46 p.m. | OK | GNU C++17 (64) | TESTS | 36 | 1965 | 265318400 |
Back to search problems