結果

問題 No.110 しましまピラミッド
ユーザー yukirinyukirin
提出日時 2016-02-27 22:58:22
言語 Go
(1.21.3)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,082 bytes
コンパイル時間 11,777 ms
コンパイル使用メモリ 215,292 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 03:52:47
合計ジャッジ時間 13,343 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

package main

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

var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	sc.Split(bufio.ScanWords)
	w := nextInt()
	ws := make([]int, w)
	for i := range ws {
		ws[i] = nextInt()
	}

	b := nextInt()
	bs := make([]int, b)
	for i := range bs {
		bs[i] = nextInt()
	}
	sort.Sort(sort.IntSlice(ws))
	sort.Sort(sort.IntSlice(bs))

	wb := []*[]int{&ws, &bs}
	counts, ends := []int{0, 0}, []int{21, 21}
	for i := 0; i < 2; i++ {
		for j := 0; j < 20; j++ {
			blocks := wb[j%2]
			if len(*blocks) == 0 || (*blocks)[0] >= ends[i] {
				break
			}

			for k := len(*blocks) - 1; k >= 0; k-- {
				if (*blocks)[k] < ends[i] {
					counts[i]++
					ends[i] = (*blocks)[k]
					*blocks = (*blocks)[:k]
					break
				}
			}
		}
		ws, bs = ws[:w], bs[:b]
		wb = []*[]int{&bs, &ws}
	}

	if counts[0] > counts[1] {
		fmt.Println(counts[0])
		return
	}
	fmt.Println(counts[1])
}

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

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}
0