-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacm.js
53 lines (40 loc) · 1.08 KB
/
acm.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
48
49
50
51
52
53
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', function(inputStdin) {
inputString += inputStdin;
});
process.stdin.on('end', function() {
inputString = inputString.split('\n');
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
const c = {};
let solved = 0;
while(1 < 2) {
let s = readLine();
if (s === '-1') break;
s = s.split(' ');
if (c.hasOwnProperty(s[1])) {
c[s[1]].attempts.push(s[2]);
c[s[1]].totT = parseInt(s[0]);
} else c[s[1]] = {
totT: parseInt(s[0]),
attempts: [s[2]]
}
if (s[2] === 'right') solved++;
}
let score = 0;
Object.values(c)
.filter(({ attempts }) => attempts.includes('right'))
.forEach(a => {
if (a.attempts.length === 1) score += a.totT;
else score += a.totT + ((a.attempts.length - 1) * 20)
});
console.log(solved, score);
}