結果
| 問題 | No.1282 Display Elements | 
| コンテスト | |
| ユーザー |  c-yan | 
| 提出日時 | 2020-11-10 12:41:01 | 
| 言語 | Go (1.23.4) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,461 bytes | 
| コンパイル時間 | 10,506 ms | 
| コンパイル使用メモリ | 232,764 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-22 17:26:28 | 
| 合計ジャッジ時間 | 11,676 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | RE * 24 | 
ソースコード
package main
import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)
func appendSorted(a []int, b int) []int {
	i := sort.Search(len(a), func(i int) bool { return a[i] >= b })
	a = append(a, 0)
	for j := len(a); j != i; j-- {
		a[j] = a[j-1]
	}
	a[i] = b
	return a
}
func main() {
	defer flush()
	N := readInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = readInt()
	}
	b := make([]int, N)
	for i := 0; i < N; i++ {
		b[i] = readInt()
	}
	sort.Ints(a)
	t0 := make([]int, 0, N)
	t1 := make([]int, 0, 300)
	result := 0
	for i := 0; i < N; i++ {
		result += sort.Search(len(t0), func(j int) bool { return t0[j] >= a[i] })
		t1 = appendSorted(t1, b[i])
		result += sort.Search(len(t1), func(j int) bool { return t1[j] >= a[i] })
		if len(t1) == 300 {
			t0 = append(t0, t1...)
			sort.Ints(t0)
			t1 = t1[:0]
		}
	}
	println(result)
}
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...)
}
            
            
            
        