본문 바로가기
개발 노트/백준, 프로그래머스 풀이

[백준 15233/javascript] Final Score

by tokkiC 2022. 9. 11.

문제가 번역이 되어 있지 않아 쫄았지만

세상 쉬운 문제였다

코딩 자체보다 영어 독해력을 묻는 문제가 아니었는가 싶을 정도...

https://www.acmicpc.net/problem/15233

 

15233번: Final Score

We have had a problem with one of our hard disks and we lost the final score of some football matches. However, we have been able to recover the names of the players that scored and found the members of each team on Wikipedia.

www.acmicpc.net

let input = [];

const readline = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

readline.on("line", (line) => {
  input.push(line);
});

readline.on("close", () => {
  solution(input);
  process.exit();
});

const solution = (inp) => {
  inp.shift();
  let amem = inp.shift().split(" ");
  let bmem = inp.shift().split(" ");
  let scoremem = inp.shift().split(" ");
  let ascore = 0;
  let bscore = 0;
  let ans;

  for (el of scoremem) {
    for (a of amem) {
      if (el === a) {
        ascore++;
      }
    }
    for (b of bmem) {
      if (el === b) {
        bscore++;
      }
    }
  }
  if (ascore > bscore) {
    ans = "A";
  } else if (ascore < bscore) {
    ans = "B";
  } else {
    ans = "TIE";
  }
  console.log(ans);
};

댓글