結果

問題 No.702 中央値を求めよ LIMITED
ユーザー c-yanc-yan
提出日時 2021-02-17 00:25:50
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,332 bytes
コンパイル時間 12,808 ms
コンパイル使用メモリ 213,928 KB
実行使用メモリ 11,988 KB
最終ジャッジ日時 2023-10-11 13:48:45
合計ジャッジ時間 48,893 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

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  = 1000
)

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