simon.kan1 9 Точки

## National Court JS

Може ли някой да каже защо judge не ми приема отговора, във VS Code ми изкарва отговорите и на 3те zero теста верни, но в judge ми дава Time needed: 0 ???

https://pastebin.com/kEP8WJ5t

# Problem 1. National Court

Every day thousands of people pass by the reception at "National Court" with various questions to ask and the employees have to help everyone by providing correct information and to answer all questions.

There are 3 employees working on the reception all day long. Each of them can handle different number of people per hour. Your task is to calculate how much time it will take to answer all the questions of a given number of people.

First you will receive 3 lines with integers, representing the count of people that each of the employee can help per hour. On the next line you will receive the total people count as a single integer.

Every fourth hour all the employees have a one-hour break before they start working again. This is the only break they get because they don`t need rest and have no personal life. Calculate the time needed to answer all people`s questions and print it in the following format: "Time needed: {time}h."

### Input / Constraints

• On first three lines -  each employee`s efficiency -  an integer in the range [1 - 100]
• On the fourth line - people count – an integer in the range [0 – 10000]
• Input will always be valid and in the range specified

### Output

• Print a single line: "Time needed: {time}h."
• Allowed working time / memory: 100ms / 16MB

### Examples

 Input Output Comment 5 6 4 20 Time needed: 2h. All employees can answer 15 people per hour. After the first hour there are 5 people left to be answered. All people will be answered in the second hour. 1 2 3 45 Time needed: 10h. All employess can answer 6 people per hour. In the first 3 hours they have answered 6 * 3 = 18 people. Then they have a break for an hour. After the next 3 hours there are 18 + 6 * 3 = 36 answered people. After the break for an hour, there are only 9 people to answer. So in the 10th hour all of the people questions would be answered. 3 2 5 40 Time needed: 5h.
Тагове:
0
MartinBG 3853 Точки

Имаше три проблема:

1. В Judge входните данни се подават като масив. Променете сигнатурата на функцията на:

``function nationalCourt([emp1, emp2, emp3, pplCount]) {``

2. Грешка в логиката, използвана за изчисляване на нужните часове. Това е оправената логика:

``````  while (pplServed > 0) {
timeNeeded++;

if (timeNeeded % 4 === 0) {
continue;
}

pplServed -= emp1;
pplServed -= emp2;
pplServed -= emp3;

}``````

3. Грешка при форматирането на изхода (липсваше 'h' след часовете). Фикс:

``console.log(`Time needed: \${timeNeeded}h.`);``

Цялото решение:

``````function nationalCourt([emp1, emp2, emp3, pplCount]) {

let pplServed = pplCount;
let timeNeeded = 0;

while (pplServed > 0) {
timeNeeded++;

if (timeNeeded % 4 === 0) {
continue;
}

pplServed -= emp1;
pplServed -= emp2;
pplServed -= emp3;

}
console.log(`Time needed: \${timeNeeded}h.`);

}``````

0
04/07/2020 19:09:53
simon.kan1 9 Точки

Мн благодаря за изчерпателния отговор

Big up

1