結果
問題 |
No.627 ランダムウォークの軌跡
|
ユーザー |
![]() |
提出日時 | 2021-02-17 23:33:47 |
言語 | TypeScript (5.7.2) |
結果 |
AC
|
実行時間 | 65 ms / 2,000 ms |
コード長 | 673 bytes |
コンパイル時間 | 8,083 ms |
コンパイル使用メモリ | 228,644 KB |
実行使用メモリ | 39,552 KB |
最終ジャッジ日時 | 2024-12-31 16:27:18 |
合計ジャッジ時間 | 10,813 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
import * as fs from 'fs'; const input = fs.readFileSync('/dev/stdin', 'utf8'); const arr1 = input.split('\n');//['3', '1', '2', '1'] let n = parseInt(arr1[0]); let result = 0; let rarr = []; let answer = 0; for (let i = 1; i < n; i++) {//条件式はあってる result = parseInt(arr1[i + 1]) - parseInt(arr1[i]) rarr.push(result);//差の配列に格納 } //console.log(rarr);//差の配列はとれてる for (let j = 0; j < n; j++) { if (Math.abs(rarr[j]) === 1) { answer = answer + 1; } } if (Math.abs(parseInt(arr1[1])) !== 1) { console.log("F"); } else if (answer === (n - 1)) { console.log("T"); } else { console.log("F"); }