結果

問題 No.702 中央値を求めよ LIMITED
ユーザー c-yan
提出日時 2021-02-17 02:13:54
言語 Go
(1.23.4)
結果
RE  
実行時間 -
コード長 1,257 bytes
コンパイル時間 11,798 ms
コンパイル使用メモリ 218,316 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-13 14:02:57
合計ジャッジ時間 14,731 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23 RE * 2
権限があれば一括ダウンロードができます

ソースコード

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...)
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0