are given a multiset of abilities of two. All the more unequivocally, for every I from 0 to n selective you have cnti components equivalent to 2i.    In one activity, you can pick any one component 2l>1 and partition it into two components 2l−1.    You ought to perform q inquiries. Each inquiry has one of two sorts:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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

You are given a multiset of abilities of two. All the more unequivocally, for every I from 0 to n selective you have cnti components equivalent to 2i. 

 

In one activity, you can pick any one component 2l>1 and partition it into two components 2l−1. 

 

You ought to perform q inquiries. Each inquiry has one of two sorts: 

 

"1 pos val" — appoint cntpos:=val; 

 

"2 x k" — ascertain the base number of tasks you really want to make basically k components with esteem lower or equivalent to 2x. 

 

Note that all inquiries of the subsequent kind don't change the multiset; that is, you simply work out the base number of activities, you don't perform them. 

 

Input 

 

The principal line contains two integers n and q (1≤n≤30; 1≤q≤2⋅105) — the size of cluster cnt and the number of inquiries. 

 

The subsequent line contains n integers cnt0,cnt1,… ,cntn−1 (0≤cnti≤106). 

 

Next q lines contain inquiries: one for each line. Each question has one of two sorts: 

 

"1 pos val" (0≤pos<n; 0≤val≤106); 

 

"2 x k" (0≤x<n; 1≤k≤1015). 

 

It's surefire that there is something like one inquiry of the subsequent kind. 

 

Output 

 

For each inquiry of the subsequent kind, print the base number of tasks you want to make basically k components with a worth lower or equivalent to 2x or −1 in case it is absolutely impossible to do it.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to classical planning
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education