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
B'Note that the memory limit is unusual. There are n chefs numbered 1, 2, ldots, n that must prepare dishes for a king. Chef i has skill i and initially has a dish of tastiness a_i where |a_i| <= q i . Each chef has a list of other chefs that he is allowed to copy from. To stop chefs from learning bad habits, the king makes sure that chef i can only copy from chefs of larger skill. There are a sequence of days that pass during which the chefs can work on their dish. During each day, there are two stages during which a chef can change the tastiness of their dish. All chefs work to maximize the tastiness of their own dish in order to please the king. Finally, you are given q queries. Each query is one of two types. Note that queries of type 1 are independent of each all other queries. Specifically, each query of type 1 is a scenario and does not change the initial tastiness a_i of any dish for future queries. Note that queries of type 2 are cumulative and only change the initial tastiness a_i of a dish. See notes for an example of queries. The first line contains a single integer n ( 1 <= n <= 300 ) -- the number of chefs. The second line contains n integers a_1, a_2, ldots, a_n ( -i <= a_i <= i ). The next n lines each begin with a integer c_i ( 0 <= c_i < n ), denoting the number of chefs the i -th chef can copy from. This number is followed by c_i distinct integers d ( i < d <= n ), signifying that chef i is allowed to copy from chef d during stage 2 of each day. The next line contains a single integer q ( 1 <= q <= 2 cdot 10^5 ) -- the number of queries. Each of the next q lines contains a query of one of two types: It is guaranteed that there is at least one query of the first type. For each query of the first type, print a single integer -- the answer to the query.'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
120631042 |
Benq |
E |
June 26, 2021, 3:33 a.m. |
OK |
GNU C++17 |
TESTS |
48 |
5007 |
6656000 |
|
|
120630826 |
Benq |
E |
June 26, 2021, 3:28 a.m. |
OK |
GNU C++17 |
TESTS |
48 |
6707 |
8294400 |
|
|
120611380 |
ecnerwala |
E |
June 25, 2021, 6:20 p.m. |
OK |
GNU C++17 (64) |
TESTS |
48 |
5381 |
6144000 |
|
|
120639544 |
sh1194 |
E |
June 26, 2021, 5:58 a.m. |
OK |
GNU C++17 (64) |
TESTS |
48 |
5428 |
6144000 |
|
|
120639180 |
sh1194 |
E |
June 26, 2021, 5:54 a.m. |
OK |
GNU C++17 (64) |
TESTS |
48 |
5428 |
6144000 |
|
|
remove filters
Back to search problems