WHY AM I GETTING ONE RUN ERROR AND ONE WRONG CASE ON SUBMISSION
my code
https://ide.codingblocks.com/s/41355
Limited budget party problem
Hey Jai, your logic is approximately correct there is just small issues
- loop over the elements of array instead of sum
- when
sum > x
you are just subtracting one element from the sum but you may need to subtract more than one element so subtract the left elements in loop with the conditionsum > x && left_idx <= right_idx
- you have taken k as int change it to long long int.
I hope this helps. If still you are unable to figure out you can refer my code.
i have put while loop instead of if as u said and it works for all kinds of inputs but on submission
1 wrong answer and one run error
please tell me what is the test case for which my code isnt able to give correct output or run properly
it works for all kinds of inputs but on submission
ONE WRONG ANSWER AND ONE RUN ERROR ON SUBMISSION
https://ide.codingblocks.com/s/41424
https://hack.codingblocks.com/contests/c/512/1239
PLEASE TELL ME MY MISTAKE OR THE TYPE OF INPUT FOR WHICH MY CODE ISNT WORKING
@LP18Aug0022
You have made very silly mistakes in your code.
Input
2
6 15
2 3 7 8 9 10
8 35
4 5 7 8 1 2 3 5
Your output
yesNo
Correct output
YES
YES
Your logic is correct
But you haven’t initialized variables like k=0 separately in each test case
And the format of the output is also not matching as required.
All this leads to wrong answer.
Try to read question more carefully from next time.