JS版
let line = parseInt(readline());
const obj = {};
for(let i = 0 ; i<line ; i++){
const arr = readline().split(" ");
if(obj.hasOwnProperty(arr[0])) {
obj[arr[0]] = Number(obj[arr[0]]) + Number(arr[1]);
} else {
obj[arr[0]] = arr[1];
}
}
for([key , value] of Object.entries(obj)){
console.log(key + " " + value);
}
京公网安备 11010502036488号