[Solution] Stone Age Problem Codeforces Solution | Codeforces Problem Solution 2022
Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another stage of the same olympiad. Since then the first Mike has been waiting for an opportunity to propose the original idea for some other contest... Mike waited until this moment!
You are given an array of integers. You are also given queries of two types:
- Replace -th element in the array with integer .
- Replace each element in the array with integer .
After performing each query you have to calculate the sum of all elements in the array.
The first line contains two integers and () — the number of elements in the array and the number of queries, respectively.
The second line contains integers () — elements of the array .
Each of the following lines contains a description of the corresponding query. Description begins with integer () which denotes a type of the query:
- If , then two integers and are following (, ) — position of replaced element and it's new value.
- If , then integer is following () — new value of each element in the array.
Print integers, each on a separate line. In the -th line print the sum of all elements in the array after performing the first queries.
Join Now for Solution:-
No comments:
Post a Comment