結果
問題 |
No.602 隠されていたゲーム2
|
ユーザー |
![]() |
提出日時 | 2021-12-01 10:58:08 |
言語 | TypeScript (5.7.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 816 bytes |
コンパイル時間 | 8,811 ms |
コンパイル使用メモリ | 228,628 KB |
実行使用メモリ | 55,376 KB |
最終ジャッジ日時 | 2024-12-31 16:41:33 |
合計ジャッジ時間 | 11,770 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 14 |
ソースコード
import * as fs from 'fs' const main = () => { const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n') const [n] = input[0].split(' ').map((x: string): number => +x) const d = input[1].split(' ').map((x: string): number => +x) const [x, y] = input[2].split(' ').map((x: string) => +x) const targetDistance = Math.abs(x) + Math.abs(y) let incrementAcc = 0 let decrementAcc = 0 for (let i = 0, len = n; i < len; i++) { if (d[i] === 0) { return console.log(0) } if (d[i] === targetDistance) { return console.log(1) } if (incrementAcc === targetDistance) { return console.log(2) } if (decrementAcc === targetDistance) { return console.log(2) } incrementAcc += d[i] decrementAcc -= d[i] } return console.log(-1) } main()