結果

問題 No.647 明太子
ユーザー ccppjsrbccppjsrb
提出日時 2020-06-28 15:50:07
言語 Go
(1.22.1)
結果
AC  
実行時間 36 ms / 4,500 ms
コード長 2,072 bytes
コンパイル時間 10,759 ms
コンパイル使用メモリ 211,968 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-09-22 02:10:44
合計ジャッジ時間 12,405 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,332 KB
testcase_01 AC 2 ms
4,336 KB
testcase_02 AC 1 ms
4,336 KB
testcase_03 AC 1 ms
4,336 KB
testcase_04 AC 2 ms
4,336 KB
testcase_05 AC 1 ms
4,332 KB
testcase_06 AC 1 ms
4,332 KB
testcase_07 AC 1 ms
4,336 KB
testcase_08 AC 2 ms
4,332 KB
testcase_09 AC 2 ms
4,332 KB
testcase_10 AC 2 ms
4,332 KB
testcase_11 AC 2 ms
4,336 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 4 ms
4,332 KB
testcase_14 AC 27 ms
4,336 KB
testcase_15 AC 4 ms
4,336 KB
testcase_16 AC 2 ms
4,332 KB
testcase_17 AC 32 ms
4,332 KB
testcase_18 AC 36 ms
4,336 KB
testcase_19 AC 3 ms
4,332 KB
testcase_20 AC 3 ms
4,336 KB
testcase_21 AC 2 ms
4,332 KB
testcase_22 AC 22 ms
4,336 KB
testcase_23 AC 2 ms
4,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	bb := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
		bb[i] = getNextInt(scanner)
	}
	m := getNextInt(scanner)
	cc := make([]int, m)
	var max cint
	for i := 0; i < m; i++ {
		x := getNextInt(scanner)
		y := getNextInt(scanner)
		for j := 0; j < n; j++ {
			if x <= aa[j] && bb[j] <= y {
				cc[i]++
			}
		}
		max.maxAs(cint(cc[i]))
	}
	if max == 0 {
		fmt.Fprintln(writer, 0)
		return
	}
	for i := 0; i < m; i++ {
		if cint(cc[i]) == max {
			fmt.Fprintln(writer, i+1)
		}
	}
}

type cint int64

func (ct *cint) minAs(x cint) *cint {
	*ct = ct.min(x)
	return ct
}
func (ct *cint) maxAs(x cint) *cint {
	*ct = ct.max(x)
	return ct
}
func (ct cint) min(x cint) cint {
	if ct > x {
		return x
	}
	return ct
}
func (ct cint) max(x cint) cint {
	if ct < x {
		return x
	}
	return ct
}
0