Unit3-thief貪婪的小偷


題目連結
搜尋 貪婪的小偷

解答

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin
});

// var lines = [];
var textA = '';
rl.on('line', function (line){
// lines.push(line);
textA = line
})

rl.on('close', function() {
slove(textA);
})

function slove(textA) {
var nums = 0;
// console.log(typeof(textA))
// console.log(textA);
var tempoB = textA.split(' ');
var c = tempoB.map(item => Number(item))
var d = c.sort(function(a,b) {
return b - a;
})
var e = d.splice(0,3)
var result = e[0] + e[1] + e[2];
console.log(toString(result))
// console.log(e)
}

Author: Jayson-Zheng
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source Jayson-Zheng !
  TOC