結果

問題 No.647 明太子
ユーザー motimoti
提出日時 2018-05-20 16:16:18
言語 Go
(1.22.1)
結果
AC  
実行時間 51 ms / 4,500 ms
コード長 1,027 bytes
コンパイル時間 16,657 ms
コンパイル使用メモリ 198,976 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 00:04:22
合計ジャッジ時間 12,782 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n := nextInt()
	var a []int
	var b []int
	for i := 0; i < n; i++ {
		co := strings.Split(nextLine(), " ")
		x, _ := strconv.Atoi(co[0])
		a = append(a, x)
		x, _ = strconv.Atoi(co[1])
		b = append(b, x)
	}
	m := nextInt()
	var x []int
	var y []int
	for i := 0; i < m; i++ {
		co := strings.Split(nextLine(), " ")
		p, _ := strconv.Atoi(co[0])
		x = append(x, p)
		p, _ = strconv.Atoi(co[1])
		y = append(y, p)
	}
	max := 0
	buy := make([]int, m)
	for i := 0; i < m; i++ {
		for k := 0; k < n; k++ {
			if x[i] <= a[k] && y[i] >= b[k] {
				buy[i]++
				if buy[i] > max {
					max = buy[i]
				}
			}
		}
	}
	if max == 0 {
		fmt.Println(0)
	} else {
		for i := 0; i < m; i++ {
			if buy[i] == max {
				fmt.Println(i + 1)
			}
		}
	}
}
0