結果

問題 No.2596 Christmas Eve (Heuristic ver.)
ユーザー ID 21712
提出日時 2025-03-06 22:22:05
言語 Go
(1.23.4)
結果
RE  
実行時間 -
コード長 1,254 bytes
コンパイル時間 12,422 ms
コンパイル使用メモリ 242,696 KB
実行使用メモリ 8,612 KB
スコア 0
最終ジャッジ日時 2025-03-06 22:22:31
合計ジャッジ時間 26,560 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 125
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import . "fmt"
import "sort"

type Unit struct {
	Id, Width, Height int
}

func main() {
	var n, k int
	Scan(&n, &k)
	tops := make([]*Unit, n)
	bodies := make([]*Unit, n*2)
	bottoms := make([]*Unit, n)
	for i := range tops {
		u := new(Unit)
		u.Id = i+1
		Scan(&u.Width)
		tops[i] = u
	}
	for _, u := range tops {
		Scan(&u.Height)
	}
	for i := range bodies {
		u := new(Unit)
		u.Id = i+1
		Scan(&u.Width)
		tops[i] = u
	}
	for _, u := range bodies {
		Scan(&u.Height)
	}
	for i := range bottoms {
		u := new(Unit)
		u.Id = i+1
		Scan(&u.Width)
		tops[i] = u
	}
	for _, u := range bottoms {
		Scan(&u.Height)
	}
	sort.Slice(tops, func(i, j int) bool {
		return tops[i].Width < tops[j].Width
	})
	sort.Slice(bodies, func(i, j int) bool {
		return bodies[i].Width < bodies[j].Width
	})
	sort.Slice(bottoms, func(i, j int) bool {
		return bottoms[i].Width < bottoms[j].Width
	})
	tops = tops[:k]
	bottoms = bottoms[len(bottoms)-k:]
	for i, top := range tops {
		btm := bottoms[i]
		body := []*Unit{}
		for len(bodies) > 0 && len(body) < 2 {
			tmp := bodies[0]
			if top.Width < tmp.Width && tmp.Width < btm.Width {
				body = append(body, tmp)
			}
			bodies = bodies[1:]
		}
		Println([]any{top.Id, body[0].Id, body[1].Id, btm.Id}...)
	}
}
0