結果

問題 No.123 カードシャッフル
ユーザー fmhrfmhr
提出日時 2015-04-27 08:49:39
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 693 bytes
コンパイル時間 10,606 ms
コンパイル使用メモリ 221,552 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2024-04-18 10:45:01
合計ジャッジ時間 11,065 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

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