結果

問題 No.133 カードゲーム
ユーザー yukirinyukirin
提出日時 2016-02-28 19:50:58
言語 Go
(1.22.1)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 1,038 bytes
コンパイル時間 14,270 ms
コンパイル使用メモリ 207,828 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 09:24:46
合計ジャッジ時間 10,836 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,380 KB
testcase_01 AC 4 ms
4,380 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 7 ms
4,376 KB
testcase_05 AC 9 ms
4,380 KB
testcase_06 AC 10 ms
4,376 KB
testcase_07 AC 8 ms
4,376 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 9 ms
4,384 KB
testcase_12 AC 10 ms
4,376 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 8 ms
4,380 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 9 ms
4,380 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 9 ms
4,380 KB
testcase_20 AC 8 ms
4,380 KB
testcase_21 AC 10 ms
4,376 KB
testcase_22 AC 9 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"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 := 0
	for i := 0; i < 50000; i++ {
		newA, newB := newA[:n], newB[:n]
		copy(newA, a)
		copy(newB, b)
		aWin, bWin := 0, 0
		for 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
}
0