結果

問題 No.63 ポッキーゲーム
ユーザー Takuya Ito
提出日時 2022-12-14 08:52:29
言語 TypeScript
(5.7.2)
結果
AC  
実行時間 68 ms / 5,000 ms
コード長 859 bytes
コンパイル時間 8,244 ms
コンパイル使用メモリ 229,164 KB
実行使用メモリ 41,464 KB
最終ジャッジ日時 2024-12-31 16:48:17
合計ジャッジ時間 10,574 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input: string): void {
  const inputArr: number[] = input.split(' ').map(str => parseInt(str));
  const totalLength = inputArr[0];
  const eatLength = inputArr[1];

  // かじることができる回数の合計(2人分)
  const eatableCount = totalLength / eatLength;

  // 1人が平等にかじる回数
  const eatableCountPerson = Math.floor(eatableCount / 2);

  // かじる回数がちょうど2人で割り切れる場合は、そのままかじると接触してしまうので、
  // ユウちゃんはその手前でかじるのを止める。そのため、その場合は1回少ない。
  const eatableCountYuu = eatableCount % 2 == 0 ? eatableCountPerson - 1 : eatableCountPerson;

  // ユウちゃんが食べた長さ
  console.log(eatLength * eatableCountYuu);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0