結果
| 問題 |
No.2596 Christmas Eve (Heuristic ver.)
|
| コンテスト | |
| ユーザー |
ID 21712
|
| 提出日時 | 2025-03-06 22:32:58 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 1,224 ms |
| コード長 | 1,310 bytes |
| コンパイル時間 | 12,131 ms |
| コンパイル使用メモリ | 238,420 KB |
| 実行使用メモリ | 8,608 KB |
| スコア | 2,383,132 |
| 最終ジャッジ日時 | 2025-03-06 22:33:25 |
| 合計ジャッジ時間 | 26,608 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 125 |
ソースコード
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)
bodies[i] = u
}
for _, u := range bodies {
Scan(&u.Height)
}
for i := range bottoms {
u := new(Unit)
u.Id = i+1
Scan(&u.Width)
bottoms[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
})
for _, btm := range bottoms[:k] {
var top *Unit
for len(tops) > 0 && top == nil {
if tops[0].Width > btm.Width {
top = tops[0]
}
tops = tops[1:]
}
body := make([]*Unit, 0, 2)
for len(bodies) > 0 && len(body) < 2 {
tmp := bodies[0]
if top.Width < tmp.Width {
body = append(body, tmp)
}
bodies = bodies[1:]
}
Println([]any{top.Id, body[0].Id, body[1].Id, btm.Id}...)
}
}
ID 21712