| UT 104c Final Exam |
|---|
| Finished |
Winter is coming. To help the state prepare for the annual freak Austin winter storm, you've volunteered to build an app that visualizes historical temperature statistics.
The state has numbered its counties from $$$1$$$ to $$$C$$$, in a way that nearby counties geographically have nearby numbers. The state has also provided you with the record low temperature recorded for each county.
Users will interact with your app in two ways.
1. They can ask your app to report the lowest recorded temperature across all counties in the range $$$[L, R]$$$ inclusive. In other words, if $$$T_i$$$ is the lowest temperature recorded for county $$$i$$$, this query asks for $$$$$$\min\left(T_L, T_{L+1}, \ldots, T_{R-1}, T_R\right).$$$$$$
2. Users can report a temperature for a county. If this temperature is lower than the lowest historical temperature in that county, you should take the new value into account for all subsequent queries.
Implement the backend for an app with this functionality.
The first line of input contains two space-separated integers $$$C$$$ $$$(1 \leq C \leq 50\,000)$$$ and $$$Q$$$ $$$(1 \leq Q \leq 100\,000)$$$: the number of counties in the state, and the number of times the user interacts with the app.
The next line contains $$$C$$$ space-separated integers $$$T_i$$$ $$$(-50 \leq T_i \leq 120)$$$: the record low temperature of each county in the state.
The final $$$Q$$$ lines record the user interactions with your app, in order. Each interaction has one of the following two forms:
It is guaranteed that at least one of the $$$Q$$$ interactions is of type QUERY.
For each interaction of type QUERY, print the requested lowest recorded temperature across those counties (see above). Print one query result per line.
5 65 -10 15 0 -2QUERY 1 5OBSERVED 2 15QUERY 1 3OBSERVED 4 -19OBSERVED 5 -3QUERY 1 5
-10 -10 -19
| Name |
|---|


