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

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter17: Markov Chains
Section: Chapter Questions
Problem 12RP
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Computer science.

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 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.

 

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Bare Bones Programming Language
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole