Polycarp is altering a convoluted PC program. To begin with, factor x is pronounced and alloted to 0. Then, at that point, there are directions of two sorts: set y v — allocate x a worth y or spend v burles to eliminate that guidance (in this way, not reassign x); in the event that y … end block — execute guidelines inside the if block if the worth of x is y and
Correct answer will be upvoted else Multiple Downvoted. Computer science.
Polycarp is altering a convoluted PC
set y v — allocate x a worth y or spend v burles to eliminate that guidance (in this way, not reassign x);
in the event that y … end block — execute guidelines inside the if block if the worth of x is y and disregard the square in any case.
if squares can contain set guidelines and other if blocks inside them.
Be that as it may, when the worth of x gets alloted to s, the PC breaks and promptly bursts into flames. Polycarp needs to keep that from occurring and spend as not many burles as could be expected.
What is the base measure of burles he can spend on eliminating set guidelines to never allot x to s?
Input
The main line contains two integers n and s (1≤n≤2⋅105, 1≤s≤2⋅105) — the number of lines in the program and the taboo worth of x.
The accompanying n lines portray the program. Each line is one of three sorts:
set y v (0≤y≤2⋅105,1≤v≤109);
if y (0≤y≤2⋅105);
end.
Each in case guidance is coordinated by an end guidance. Each end guidance has an if guidance to coordinate.
Output
Print a solitary integer — the base measure of burles Polycarp can spend on eliminating set directions to never relegate x to s.
Step by step
Solved in 3 steps with 1 images