結果
| 問題 | No.365 ジェンガソート | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-03-13 10:30:54 | 
| 言語 | TypeScript (5.7.2) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 647 bytes | 
| コンパイル時間 | 8,242 ms | 
| コンパイル使用メモリ | 229,104 KB | 
| 実行使用メモリ | 51,128 KB | 
| 最終ジャッジ日時 | 2024-12-31 16:34:47 | 
| 合計ジャッジ時間 | 23,389 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 16 WA * 25 | 
ソースコード
import * as fs from 'fs';
function main(input: Array<string>) {
    const n = Number(input[0]);
    const block_length_list = input[1].split(' ').map(x => Number(x));
    
    let head = block_length_list[0];
    const min_length = 1;
    let counter = 0;
    
    while(head != min_length) {
        swap(0, block_length_list.indexOf(head - 1), block_length_list);
        head = block_length_list[0];
        counter++;
    }
    
    console.log(counter);
}
function swap(origin, target, list) {
    const tmp = list[origin];
    list[origin] = list[target];
    list[target] = tmp;
}
main(fs.readFileSync('/dev/stdin', 'utf8').split('\n'));
            
            
            
        