Please check my code what's wrong in it

#include
#include
using namespace std;
#define ll long long int
ll PainterProblem(ll arr[],ll n,ll k,ll t){
int M=10000003;
int worker=0;
ll max_time=1;
for(ll i=0;i<n;i++){
ll per_worker_time=(arr[i]*t)%M;

    max_time=max(max_time,per_worker_time);
    worker++;
    if(worker==k){
        return max_time;
    }
}

}
int main() {
ll n,k,t;
cin>>n>>k>>t;
ll arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
cout<<PainterProblem(arr,n,k,t);
return 0;
}

your approach is not correct
this is similar to book allocation problem
have you done it?

i tried to approach as i did book allocation problem ,would please tell me what i need to change in program

int main() {
ll n,k,t;
cin>>n>>k>>t;
ll arr[n];
ll sum=0;
for(ll i=1;i<=n;i++){
cin>>arr[i];
sum+=arr[i];
}
ll s=0,mid=0,e=sum;
ll ans=0;

while(s<=e){
    mid=(s+e)/2;
    if(isvalid(arr,n,k,mid,t)){

       ans=mid*Time;  //you should have to consider time here only
        ans%=m;
        e=mid-1;
    }
    else{
        s=mid+1;
    }
    
}
cout<<ans<<endl;
return 0;

}

now define isvalid function which is simillar to book allocation problem