fork download
  1. function finn() {
  2. let input1 = readline();
  3. let input2 = readline();
  4. let splited = input1.split(',');
  5. let N = Number(splited[0]);
  6. let P = Number(splited[1]);
  7. let J = Number(splited[2]);
  8. let A = input2.split(',');
  9.  
  10. //console.log('input1', input1);
  11. //console.log('input2', input2);
  12. //console.log('A', A);
  13.  
  14. A.map(e => Number(e)).sort((a, b) => a - b);
  15. let count = 0;
  16.  
  17. for (let i = 0; i < N; i++) {
  18. if (A[i] < P) {
  19. P += A[i];
  20. } else if (count < 3 && A[i] < (P + J) * 2) {
  21. P += Math.floor(A[i] / 2);
  22. count++;
  23. } else {
  24. return "NO";
  25. }
  26. }
  27.  
  28. return "SI";
  29. }
  30.  
  31. console.log(finn());
  32.  
Success #stdin #stdout 0.03s 16956KB
stdin
4, 3, 1
2, 1, 9, 7
stdout
SI