結果
問題 | No.702 中央値を求めよ LIMITED |
ユーザー |
![]() |
提出日時 | 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 |
ソースコード
package mainimport ("bufio""fmt""os""sort""strconv")var (x uint32 = 0y uint32 = 1z uint32 = 2w uint32 = 3)func xorshift() uint32 {var t uint32 = x ^ (x << 11)x = yy = zz = ww = (w ^ (w >> 19)) ^ (t ^ (t >> 8))return w}const (totalCount = 10000001l = (1 << 31) - (1<<31)/1000r = (1 << 31) + (1<<31)/1000)func main() {defer flush()x = uint32(readInt())t := make([]int, 0, totalCount/1000)c := 0for 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...)}