Wrong answer in a simple program
Here link: Question
Tag: LECANDY
My approach
#include
using namespace std;
int main()
{
int t;
cin>>t;
while(tβ)
{
int n,sum=0,i;
int c;
cin>>n>>c;
int a[n];
for(i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
}
if(sum<=c)
cout<<βYESβ<<endl;
else
cout<<βNOβ<<endl;
}
}
Please anyone help
1 Like
It is mentioned in the question that the output should be Yes or No instead of YES or NO
2 Likes
Hey yeah I got it Thank you i have to keep eyes on that also thank you again
1 Like
test = int(input())
elephantf=0
candyf=0
maxcan=0
lst=[]
for i in range(test):
elephant,candy=input().split()
elephantf=int(elephant)
candyf=int(candy)
hap=map(int, input().split())
hapf=list(hap)
for j in range(len(hapf)):
maxcan+=hapf[j]
if maxcan<=candyf:
lst.append('Yes')
else:
lst.append('No')
for z in range(len(lst)):
print(lst[z])
I solved this question in python and I am getting wrong answer can anyone tell me why?