LOSTWKND - Editorial

I can’t figure out why I’m getting WA. Any help would be appreciated.

‘’’
#include
#include
#include
using namespace std;
int main()
{

int t, p, sum=0;
int a[5];
cin>>t;
vector<string> ans;
for(int j=0; j<t; j++)
{
for(int i=0; i<5; i++)
{
    cin>>a[i];
    sum=sum+a[i];
}
cin>>p;
if((sum*p)>120)
{cout<<"YES"<<"\n";}
    //ans.push_back("YES");}
else
{cout<<"NO"<<"\n";
    //ans.push_back("NO");}
}
}
//for(int k=0; k<t; k++)
//{cout<<ans[k]<<endl;}

return 0;
}
‘’’

Since you have declared your variable sum outside the for loop of testcases it retains the value of previous testcases. You can do two things either declare variable sum inside the for loop of testcase or after last line of code do “sum=0;”. This will reset you sum to be zero for each testcase.
Also you have to print “No” instead of “NO” and “Yes” instead of “YES”

i have written t–…but i dont know why this is showing t-

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine().trim());
for(int i=0;i<t;i++)
{
String a[]=br.readLine().trim().split(" ");
int sum=0;
for(int k=0;k<a.length-1;k++)
{
sum=sum+Integer.parseInt(a[k])Integer.parseInt(a[5]);
}
if(sum>(24
5))
{
System.out.println(“YES”);
}
else
{
System.out.println(“NO”);
}
}
}
}

WHEN I SUBMIT IT IS SHOWING WRONG ANSWER
PLEASE HELP WHERE IS THE MISTAKE IN CODE

https://www.codechef.com/viewsolution/33454761
^^ check it out :neutral_face:

1 Like

The if condition should be if(sum>120) because he will have 120 hours in weekdays(24*5).
And you have to print “Yes” instead of “YES” and “No” instead of “NO”.

python solution
t = int(input())

for i in range(t):
l = []
arr = list(map(int,input().split()))
p = arr.pop()
arr = [i*p for i in arr]
new = sum(arr)
if new > 120:
print(“Yes”)
else:
print(“No”)

for _ in range(int(input())):
a = list(map(int, input().split()))
p = a[5]
if((a[0] + a[1] + a[2] + a[3] + a[4])*p > 120):
print(“Yes”)
else:
print(“No”)

^^ PYTH 3.6
Problem link: LOSTWKND Problem - CodeChef
Submit link: CodeChef: Practical coding for everyone
Solution link: CodeChef: Practical coding for everyone
Discussion link: LOSTWKND - Editorial - #39 by ritz1804

:+1:

1 Like

There is difference in “YES” and “Yes” and same for NO and No

yes because output is case sensitive and codechef will give WA for YES and NO in this question as i have already mentioned above

class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int tcs = sc.nextInt();
while(tcs > 0) {
int sum = 0;
for(int i = 0; i<5; i++){
sum = sum + sc.nextInt();
}
int p = sc.nextInt();
if((sum * p) <= 120) {
System.out.println(“Yes”);
} else {
System.out.println(“No”);
}
tcs–;
}

}

}

Getting WA for this piece. Can someone point out?

Read the problem statement again, this time ready it carefully.

1 Like

Hi
A[0]=A1
A[1]=A2
A[2]=A3
A[3]=A4
A[4]=A5
sum=0
sum=sum+A[0]+A[1]+A[2]+A[3]+A[4]
mix=P*sum
if mix>125
print yes
else print no

I hope its clear and useful

it should be mix > 120, not 125. I’m guessing it’s a typo

https://www.codechef.com/viewsolution/33454761

Yes, You are right its 5 * 24 = 120
but
what is typo?

1 Like

Typo is slang for typing error

#include<bits/stdc++.h>
using namespace std;
int main(){
	int t,p;
	cin>>t;
	while(t--){
		vector<int> a(5);
		for(auto &it: a) cin>>it;
		cin>>p;
	        for(int i=0;i<(int)a.size();i++){
			a[i]=a[i]*p;
		}
		int x=accumulate(a.begin(),a.end(),0);
		
		if(x>120)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}

Why the above code shows Runtime Error(SIGCONT)?
Frustrating!
Please Help.
Its running just fine on my machine as well as geeksforgeeks IDE…I think something is wrong with CodeChef IDE !

#include <bits/stdc++.h>
using namespace std;

int main(){
int x,a[5],c,y;
cin>>x;
while(x!=0) {c=0;
for(int i=0;i<5;i++){
cin>>a[i];}
cin>>y;
for(int i=0;i<5;i++){
c=c+a[i]*y;}
if(c<=120)
{ cout<<“No\n”;}
else
{ cout<<“Yes\n”;}
x–;
}
return 0;
}
Please help me…I am getting runtime error SIGCONT.


c++