Skip to content

Instantly share code, notes, and snippets.

@breakstorm
Created February 17, 2017 03:53
Show Gist options
  • Save breakstorm/30b18a1858c17b0c0f173765e6726004 to your computer and use it in GitHub Desktop.
Save breakstorm/30b18a1858c17b0c0f173765e6726004 to your computer and use it in GitHub Desktop.
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
process.stdin.on('end', function () {
input_stdin_array = input_stdin.split("\n");
main();
});
function readLine() {
return input_stdin_array[input_currentline++];
}
/////////////// ignore above this line ////////////////////
function main() {
var n = parseInt(readLine());
arr = readLine().split(' ');
arr = arr.map(Number);
var countPlus = 0;
var countMinus = 0;
var countZero = 0;
arr.forEach(function(value){
if(value > 0) countPlus ++;
else if(value < 0 ) countMinus ++;
else countZero ++;
});
console.log(countPlus/n);
console.log(countMinus/n);
console.log(countZero/n);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment