치춘짱베리굿나이스

[백준] 24736 본문

Javascript + Typescript/자바스크립트로 알고리즘풀기

[백준] 24736

치춘 2022. 7. 16. 00:37

Football Scoring

문제

There are five ways to score points in american professional football:

  1. Touchdown - 6 points
  2. Field Goal - 3 points
  3. Safety - 2 points
  4. After touchdown
    1. 1 point (Field Goal or Safety) - Typically called the “Point after”
    2. 2 points (touchdown) - Typically called the “Two-point conversion”

(https://operations.nfl.com/the-rules/nfl-video-rulebook/scoring-plays/)

Given the box score values for two competing teams, calculate the point total for each team.

입력

There are two lines of input each containing five space-separated non-negative integers, T, F, S, P and C representing the number of Touchdowns, Field goals, Safeties, Points-after-touchdown and two-point Conversions after touchdown respectively. (0 ≤ T ≤ 10), (0 ≤ F ≤ 10), (0 ≤ S ≤ 10), (0 ≤ (P+C) ≤ T). The first line represents the box score for the visiting team, and the second line represents the box score for the home team.

출력

The single output line consists of two space-separated integers showing the visiting score and the home score respectively.

풀이

const football = () => {
  let [v, h] = require("fs")
    .readFileSync("/dev/stdin")
    .toString()
    .trim()
    .split("\n")
    .map((v) => v.split(" ").map(Number));
  console.log(
    `${v[0] * 6 + v[1] * 3 + v[2] * 2 + v[3] * 1 + v[4] * 2} ${
      h[0] * 6 + h[1] * 3 + h[2] * 2 + h[3] * 1 + h[4] * 2
    }`
  );
};

football();

'Javascript + Typescript > 자바스크립트로 알고리즘풀기' 카테고리의 다른 글

[백준] 24262  (0) 2022.07.16
[백준] 24568  (0) 2022.07.16
[백준] 25311  (0) 2022.07.14
[백준] 25314  (0) 2022.07.14
[백준] 18301  (0) 2022.07.14
Comments