結果

問題 No.123 カードシャッフル
ユーザー fmhrfmhr
提出日時 2015-04-27 08:50:23
言語 Go
(1.22.1)
結果
AC  
実行時間 374 ms / 5,000 ms
コード長 693 bytes
コンパイル時間 10,702 ms
コンパイル使用メモリ 241,092 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-04-18 10:45:42
合計ジャッジ時間 12,664 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 249 ms
6,016 KB
testcase_11 AC 374 ms
6,400 KB
testcase_12 AC 360 ms
6,400 KB
testcase_13 AC 360 ms
6,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
    "fmt"
)


func pop(a []int, x int) ([]int, int) {
    var r int
    r = a[x]
    if x == len(a)-1 {
        a = a[:x]
    } else {
        a = append(a[:x], a[x+1:]...)
    }
    return a, r
}

func main() {
    var N, M int
    fmt.Scan(&N, &M)
    s := make([]int, N)
    for i := 0; i<N; i++ {
        s[i] = i
    }
    //    fmt.Println(s)
    var a int
    for i := 0; i<M; i++ {
        fmt.Scan(&a)
        a -= 1
        s, a = pop(s, a)
        tmp_slice := []int{a}
        //        fmt.Println(s)
        //        fmt.Println(a)
        s = append(tmp_slice, s[:]...)
        //        fmt.Println(s)
    }
    fmt.Println(s[0]+1)
//    print(s[0]+1)
}
0