TIme Limit Exceeded

Solved the question as far the given input and required outputs are concerned. Don’t know what optimisation it needs.

@avikaldarolia7
hello avikal,
use segment tree to answer query efficiently

#include<bits/stdc++.h>
using namespace std;
#define ll long long int

ll query(vector&tree,int ss, int se, int l, int r, int index){
if(l<=ss&&se<=r){
return tree[index];
}
if(r<ss||l>se){
return INT_MAX;
}
ll mid=(ss+se)/2;
ll left=query(tree,ss,mid,l,r,2index);
ll right=query(tree,mid+1,se,l,r,2
index+1);

return min(left,right);

}
void build(vector&a,vector&tree, int ss, int se,int index){
if(ss==se){
tree[index]=a[ss];
return;
}
int mid=(ss+se)/2;
build(a,tree,ss,mid,2index);
build(a,tree,mid+1,se,2
index+1);
tree[index]=min(tree[2index],tree[2index+1]);

return;

}
void func(){

}
int main(int argc, char const *argv[])
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll n,q;
//cin>>n>>q;
scanf("%lld %lld",&n,&q);
vector<ll>a(n);

for (int i = 0; i < a.size(); i++)
{
    scanf("%lld",&a[i]);
}
vector<ll>tree(4*n+1);
build(a,tree,0,n-1,1);


for (int i = 0; i < q; i++)
{
    ll f,s,t;
    //cin>>f>>s>>t;
    scanf("%lld %lld %lld",&f,&s,&t);
    if(f&1==1){
        cout<<query(tree,0,n-1,s-1,t-1,1)<<endl;
    }
    else{
        a[s-1]=t;
        build(a,tree,0,n-1,1);
       
    }
}
return 0;

}