結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2016-02-28 19:50:58 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 11 ms / 5,000 ms |
コード長 | 1,038 bytes |
コンパイル時間 | 14,655 ms |
コンパイル使用メモリ | 233,552 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 03:42:49 |
合計ジャッジ時間 | 15,742 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
package mainimport ("bufio""fmt""math/rand""os""strconv""time")var sc = bufio.NewScanner(os.Stdin)var rdr = bufio.NewReaderSize(os.Stdin, 1000000)func main() {sc.Split(bufio.ScanWords)n := nextInt()a, b := make([]int, n), make([]int, n)r := rand.New(rand.NewSource(time.Now().UnixNano()))for i := range a {a[i] = nextInt()}for i := range b {b[i] = nextInt()}newA, newB := make([]int, n), make([]int, n)wC := 0for i := 0; i < 50000; i++ {newA, newB := newA[:n], newB[:n]copy(newA, a)copy(newB, b)aWin, bWin := 0, 0for j := 0; j < n; j++ {aI, bI := r.Intn(len(newA)), r.Intn(len(newB))aH, bH := newA[aI], newB[bI]newA = append(newA[:aI], newA[aI+1:]...)newB = append(newB[:bI], newB[bI+1:]...)if aH > bH {aWin++} else if bH > aH {bWin++}}if aWin > bWin {wC++}}fmt.Println(float64(wC) / 50000)}func nextLine() string {sc.Scan()return sc.Text()}func nextInt() int {i, _ := strconv.Atoi(nextLine())return i}