Advertisement
Guest User

.map???

a guest
Apr 29th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     input = input.map(x => Number(x))
  3.     let students = input.shift()
  4.     let lectures = input.shift()
  5.     let initBonus = input.shift()
  6.     let highestScore = 0;
  7.     let totalBonus = 0;
  8.     for (let i = 0; i < students; i++) {
  9.         let student = input[i];
  10.         if (student <= lectures) {
  11.             if (student > highestScore) {
  12.                 highestScore = student;
  13.                 totalBonus = Math.ceil(highestScore / lectures * (5 + initBonus))
  14.             }
  15.         }
  16.  
  17.     }
  18.     console.log(`Max Bonus: ${totalBonus}.`);
  19.     console.log(`The student has attended ${highestScore} lectures.`);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement