結果

問題 No.48 ロボットの操縦
ユーザー intercept6intercept6
提出日時 2020-09-10 15:27:07
言語 TypeScript
(5.2.2)
結果
WA  
実行時間 -
コード長 848 bytes
コンパイル時間 9,590 ms
コンパイル使用メモリ 255,556 KB
実行使用メモリ 42,680 KB
最終ジャッジ日時 2023-08-24 22:46:28
合計ジャッジ時間 12,746 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
41,636 KB
testcase_01 AC 77 ms
41,668 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 77 ms
41,612 KB
testcase_05 AC 79 ms
41,616 KB
testcase_06 AC 77 ms
41,736 KB
testcase_07 AC 78 ms
41,856 KB
testcase_08 WA -
testcase_09 AC 79 ms
42,348 KB
testcase_10 WA -
testcase_11 AC 78 ms
41,648 KB
testcase_12 AC 80 ms
41,860 KB
testcase_13 AC 79 ms
41,820 KB
testcase_14 AC 79 ms
41,820 KB
testcase_15 AC 79 ms
42,612 KB
testcase_16 AC 77 ms
41,728 KB
testcase_17 AC 77 ms
41,756 KB
testcase_18 WA -
testcase_19 AC 77 ms
41,844 KB
testcase_20 AC 78 ms
41,760 KB
testcase_21 AC 77 ms
41,752 KB
testcase_22 WA -
testcase_23 AC 76 ms
41,744 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import { readFileSync } from 'fs';

function Main(input: string) {
  const data = input.split('\n');

  const positionX = parseInt(data[0]);
  const positionY = parseInt(data[1]);
  const distance = parseInt(data[2]);

  let step = 0;

  // Y軸方向へ正方向の移動(↑)を行う場合
  if (positionY > 0) {
    step += Math.ceil(positionY / distance);
  }

  // X軸へ移動(←→)を行う場合
  // 絶対値を取って計算する
  if (positionX !== 0) {
    step++; //  回転
    step += Math.ceil(Math.abs(positionX) / distance);
  }

  // Y軸方向へ負方向の移動(↓)を行う場合
  if (positionY < 0) {
    if (positionX !== 0) {
      step += 2;
    } else {
      step++;
    }

    step += Math.ceil((-1 * positionY) / distance);
  }

  console.log(step);
}

Main(readFileSync('/dev/stdin', 'utf8'));
0