-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray_of_zeros1.js
47 lines (43 loc) · 923 Bytes
/
array_of_zeros1.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function runProgram(input){
var input_arr = input.trim().split("\n")
input_arr.shift()
var array = input_arr[0].split(" ").map(Number)
var odd_sum = 0
var even_sum = 0
for(var i = 0; i < array.length; i++)
{
if(i%2 == 0)
{
even_sum += array[i]
}
else
{
odd_sum += array[i]
}
}
if(odd_sum == even_sum)
{
console.log("YES")
}
else
{
console.log("NO")
}
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
let read = "";
process.stdin.on("data", function (input) {
read += input;
});
process.stdin.on("end", function () {
read = read.replace(/\n$/,"")
runProgram(read);
});
process.on("SIGINT", function () {
read = read.replace(/\n$/,"")
runProgram(read);
process.exit(0);
});
runProgram(`2
1 2`)