LOSTWKND - Editorial

Did it pass samples on CodeChef IDE or just your computer? Either way, it’s probably the multitests causing sum to have some garbage value.

on my computer as well as on ideone…
probably were the multitests

what about CodeChef IDE

thanks got it. it was the multitests causing it to go haywire

import java.io.;
import java.lang.
;
import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int t,p;
t=in.nextInt();
for(int i=t;i>0;i–)
{
int a[]=new int[5];
for(int j=0;j<5;j++)
{
a[j]=in.nextInt();
}
p=in.nextInt();
long sum=0,s=0;
for(int j=0;j<5;j++)
{
sum=sum+a[j];
}
if((sum*p) > 120)
System.out.println(“YES”);
else
System.out.println(“NO”);
}
}
}

same method still getting WA

Output may be case-sensitive

Also format your code

t=int(input())
for f in range(t):
l=[int(x) for x in input().split()]
sums=0
for i in range(5):
sums+=l[i]
sums=sums*l[5]
if(sums>144):
print(“YES”)
else:
print(“NO”)

Pls someone tell why this is not working

t=int(input())

for f in range(t):
l=[int(x) for x in input().split()]
sums=0
for i in range(5):
sums+=l[i]
sums=sums*l[5]
if(sums>144):
print(“YES”)
else:
print(“NO”)

Firstly, a workweek here is 5 days. So sum need to be greater than 120 only rather than 144.
Secondly, the output might be case sensitive.

@admin @everyone
I have done a similar approach and compared maximum work that can be done per day * 5 versus sum.
Why was this a WA as I have just transferred { Editorial : p * sum > 120 } to { sum > ( 120 / p ) }

Full code can be found here : CodeChef: Practical coding for everyone
int main()
{
tc
{
lli a[5] = {0}, p = 1;
aip(a, 5);
lli sum = 0;
rep(i, 0, 5)
sum += a[i];
cin >> p;
lli max = (24 / p) * 5;

	if (max >= sum)
		cout << "No\n";
	else
		cout << "Yes\n";
}
return 0;

}

By dividing the no of available hours from each day with p, you are discarding the fractional value which might affect the answer.

Sample test run but still getting WA

public static void main(String[] args) throws java.lang.Exception {
	List<Integer> numbers = new ArrayList<>(5);
	Scanner sc = new Scanner(System.in);

	IntStream.range(0, 5).forEach(x -> { 
		numbers.add(x, sc.nextInt()); 
	});	

	List<Integer> totalWorkingHours = new ArrayList<>();

	int pHour = sc.nextInt();

	numbers.forEach(workHour -> {
		int totalHourPerDay = workHour*pHour;
		totalWorkingHours.add(totalHourPerDay);
	});

	if (new Codechef().sumOfWeekdayHours(totalWorkingHours) <= 120) {
		System.out.println("No");
	} else {
		System.out.println("Yes");
	}
}
public int sumOfWeekdayHours(List<Integer> totalWorkingHours) {
	int sum = 0; 
	for (int weekdayHour : totalWorkingHours) {
		sum = sum + weekdayHour;
	}
	return sum;
}

Oh yep it’s correct. Thanks bro ! What a silly mistake :frowning: anyways learnt something

can anyone please say what is wrong in this code please reply

#include
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
int a[5];
int count=0;
for(int i=0;i<5;i++)
{
cin>>a[i];
}
int P;
cin>>P;

    for(int i=0 ;i<5;i++)
    {
        a[i]=a[i]*P;
    }
    for(int i=0 ;i<5;i++)
    {
        count+=a[i];
    }
    if(count<=120)
    {
        cout<<"NO\n";
    }
    else
    {
        cout<<"YES\n";
    }
}

}

why i am getting runtime NZEC error in this code

package Problems;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

import java.util.StringTokenizer;

class work {
static class FastReader {
BufferedReader br;
StringTokenizer st;

	public FastReader() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}
public static void main(String[] args) throws IOException {
	try {
		FastReader obj = new FastReader();
		int testcase = obj.nextInt();
		for (int i = 0; i < testcase; i++) {
			int sum = 0;
			int[]array = new int[5];
			for (int j = 0; j < array.length; j++) {
				array[j] = obj.nextInt();
			}
			int p = obj.nextInt();
			for (int j = 0; j < array.length; j++) {
				sum = sum+array[j]*p;
			}	
			if (sum >120) {
				System.out.println("Yes\n");
			} else {
				System.out.println("No\n");
			}
		}

	} catch (java.lang.Throwable t) {
		System.out.println(t);
	}

}

}

:rofl: :rofl: :rofl: The same error what I did during contest.Print “Yes” and “No” but your code is printing "YES and “NO”.

Whats wrong with my code?
#include <bits/stdc++.h>
#include
using namespace std;

int main() {
// your code goes here
int t;cin>>t;
while(t–)
{
int arr[5]={0};
for(int i=0;i<5;i++)
{
cin>>arr[i];
}
int p;cin>>p; int sum=0;
for(int i=0;i<5;i++)
{
arr[i]=arr[i]*p;
sum+=arr[i];
}

     if(sum/24<=5)
     {
          cout<<"No"<<endl;
     }
     else
     {
          cout<<"Yes"<<endl;
     }
}
return 0;

}

If sum is between 120 and 144. Since we are having integer division it will be 5 only, Hence , Condition in if will be true while it should be false.

why my code is showing error…very frustating …

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll t;
cin>>t;
while(t–)
{
ll a[5],i,p,sum=0;
for( i=0;i<5;i++)
{
cin>>a[i];
sum+=a[i];}
cin>>p;

if(sum*p >5*24 )
cout<<"YES\n";
else
cout<<"NO\n";

}
return 0;
}

It should be while(t–) instead of (t-)