結果

問題 No.702 中央値を求めよ LIMITED
ユーザー c-yanc-yan
提出日時 2021-02-17 02:13:54
言語 Go
(1.21.3)
結果
RE  
実行時間 -
コード長 1,257 bytes
コンパイル時間 11,237 ms
コンパイル使用メモリ 211,988 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-11 15:13:03
合計ジャッジ時間 14,796 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
4,352 KB
testcase_01 AC 76 ms
4,352 KB
testcase_02 AC 77 ms
4,348 KB
testcase_03 AC 76 ms
4,356 KB
testcase_04 AC 77 ms
4,356 KB
testcase_05 AC 77 ms
4,348 KB
testcase_06 AC 77 ms
4,372 KB
testcase_07 AC 77 ms
4,348 KB
testcase_08 AC 76 ms
4,352 KB
testcase_09 AC 77 ms
4,348 KB
testcase_10 AC 77 ms
4,352 KB
testcase_11 AC 76 ms
4,348 KB
testcase_12 AC 76 ms
4,356 KB
testcase_13 AC 76 ms
4,348 KB
testcase_14 RE -
testcase_15 AC 76 ms
4,348 KB
testcase_16 AC 76 ms
4,348 KB
testcase_17 AC 77 ms
4,352 KB
testcase_18 AC 76 ms
4,348 KB
testcase_19 AC 77 ms
4,352 KB
testcase_20 AC 76 ms
4,356 KB
testcase_21 AC 77 ms
4,348 KB
testcase_22 AC 76 ms
4,352 KB
testcase_23 AC 76 ms
4,356 KB
testcase_24 AC 77 ms
4,348 KB
testcase_25 RE -
testcase_26 AC 77 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	x uint32 = 0
	y uint32 = 1
	z uint32 = 2
	w uint32 = 3
)

func xorshift() uint32 {
	var t uint32 = x ^ (x << 11)
	x = y
	y = z
	z = w
	w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))
	return w
}

const (
	totalCount = 10000001
	l          = (1 << 31) - (1<<31)/1000
	r          = (1 << 31) + (1<<31)/1000
)

func main() {
	defer flush()

	x = uint32(readInt())

	t := make([]int, 0, totalCount/1000)
	c := 0
	for i := 0; i < totalCount; i++ {
		a := int(xorshift())
		if a < l {
			c++
		} else if a < r {
			t = append(t, a)
		}
	}
	sort.Ints(t)
	println(t[totalCount/2-c])
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}
0