Why is the code wrong? Question code: LOSTWKND

   #include<iostream>

   int main(){
   int t;
   std::cin>>t;
   while(t--){
    
    int arr[5];
    int p;
    for(int i=0; i<5; i++){
        std::cin>>arr[i];
    }
    std::cin>>p;
    int sum=0;
    for(int i=0; i<5; i++){
        sum+=arr[i];
    }
    sum=sum*p;
    if(sum<=120){
      std::cout<<"NO"<<std::endl;  
    }else{
        std::cout<<"YES"<<std::endl;
    }
}
}

the array declaration is wrong. you need to accept 6 values in the array, 5 days a week along with a P at the last but you didn’t . rest of the code is correct, it seems

1 Like

I stored the value of p in “int p”.

see the test case, the value of p is getting entered in the array.