結果

問題 No.702 中央値を求めよ LIMITED
ユーザー c-yan
提出日時 2021-02-17 02:14:46
言語 Go
(1.23.4)
結果
AC  
実行時間 88 ms / 5,000 ms
コード長 1,254 bytes
コンパイル時間 16,383 ms
コンパイル使用メモリ 235,128 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-22 22:59:27
合計ジャッジ時間 15,712 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

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)/100
r = (1 << 31) + (1<<31)/100
)
func main() {
defer flush()
x = uint32(readInt())
t := make([]int, 0, totalCount/100)
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