結果

問題 No.193 筒の数式
ユーザー c-yanc-yan
提出日時 2021-02-17 00:23:48
言語 Go
(1.22.1)
結果
RE  
実行時間 -
コード長 1,333 bytes
コンパイル時間 12,353 ms
コンパイル使用メモリ 213,988 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-11 13:46:32
合計ジャッジ時間 13,709 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 (
	totalSize = 10000001
	buffSize  = 10000
)

func main() {
	defer flush()

	x = uint32(readInt())

	t := make([]int, 0, totalSize/10+1)
	buff := make([]int, buffSize)
	for i := 0; i < totalSize/buffSize; i++ {
		for j := 0; j < buffSize; j++ {
			buff[j] = int(xorshift())
		}
		sort.Ints(buff)
		a := (buffSize - (buffSize / 10)) / 2
		t = append(t, buff[a:a+buffSize/10]...)
	}
	t = append(t, int(xorshift()))
	sort.Ints(t)
	println(t[len(t)/2])
}

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