結果

問題 No.627 ランダムウォークの軌跡
コンテスト
ユーザー megane_anko
提出日時 2021-02-17 23:29:39
言語 TypeScript
(6.0.2)
コンパイル:
tsc.sh -p tsconfig.json
実行:
node main.js ONLINE_JUDGE
結果
WA  
実行時間 -
コード長 663 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,845 ms
コンパイル使用メモリ 350,316 KB
実行使用メモリ 53,232 KB
最終ジャッジ日時 2026-06-05 05:06:24
合計ジャッジ時間 9,575 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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 (parseInt(arr1[1]) === 0) {
    console.log("F");
} else if (answer === (n - 1)) {
    console.log("T");
} else {
    console.log("F");
}
0