Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- //#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
- #define pb push_back
- #define mp make_pair
- #define fi first
- #define se second
- #define gcd __gcd
- #define getl(s) getline(cin, s);
- #define setpre(x) fixed << setprecision(x)
- #define mset(a) memset(a, 0, sizeof(a))
- #define endl '\n'
- const int N=200050,M=1000000007;
- const ll INF=1e18+7;
- int a[N],p[4*N],val,pos,lo,hi;
- void Build(int x,int L,int R){
- if(L==R){
- p[x]=a[L];
- return;
- }
- int mid=(L+R)/2;
- Build(2*x,L,mid);
- Build(2*x+1,mid+1,R);
- p[x]=min(p[2*x],p[2*x+1]);
- return;
- }
- void Update(int x,int L,int R){
- if(L==R){
- p[x]=val;
- return;
- }
- int mid=(L+R)/2;
- if(pos<=mid) Update(2*x,L,mid);
- else Update(2*x+1,mid+1,R);
- p[x]=min(p[2*x],p[2*x+1]);
- return;
- }
- int Query(int x,int L,int R){
- if(lo<=L&&R<=hi){
- return p[x];
- }
- else if(L>hi||R<lo){
- return M;
- }
- int mid=(L+R)/2;
- return min(Query(2*x,L,mid),Query(2*x+1,mid+1,R));
- }
- int main(){
- ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);
- // freopen(".inp","r",stdin);
- // freopen(".out","w",stdout);
- int n,t,x,y,q;
- cin>>n>>t;
- for(int i=1;i<=n;++i){
- cin>>a[i];
- }
- Build(1,1,n);
- while(t--){
- cin>>q>>x>>y;
- if(q==1){
- pos=x;
- val=y;
- Update(1,1,n);
- }
- else{
- lo=x; hi=y;
- cout<<Query(1,1,n)<<endl;
- }
- }
- return 0;
- }
- /*
- ==================================+
- INPUT: |
- ------------------------------ |
- ------------------------------ |
- ==================================+
- OUTPUT: |
- ------------------------------ |
- ------------------------------ |
- ==================================+
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement