結果
問題 |
No.5004 Room Assignment
|
ユーザー |
![]() |
提出日時 | 2025-03-06 00:17:57 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 266 ms / 5,000 ms |
コード長 | 1,312 bytes |
コンパイル時間 | 12,407 ms |
コンパイル使用メモリ | 246,720 KB |
実行使用メモリ | 26,228 KB |
スコア | 45,662,268 |
平均クエリ数 | 6557.06 |
最終ジャッジ日時 | 2025-03-06 00:18:38 |
合計ジャッジ時間 | 40,736 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
package main import . "fmt" import "sort" type Player struct { Id int Entered int Skill int } func main() { var t, r int Scan(&t, &r) ps := []*Player{} id := 0 for ti := 0; ti < t; ti++ { var n int Scan(&n) for i := 0; i < n; i++ { var s int Scan(&s) id++ p := &Player{ Id: id, Entered: ti, Skill: s, } ps = append(ps, p) } sort.Slice(ps, func(i, j int) bool { if d := ps[i].Skill-ps[j].Skill; d != 0 { return d < 0 } else { return ps[i].Entered < ps[j].Entered } }) con := []int{} for i := 0; i+1 < len(ps); i++ { bestx, bests := 0, 0 for x := 2; x <= r && i+x <= len(ps); x++ { min, max := ps[i].Skill, ps[i].Skill e := (ti-ps[i].Entered)*(x-1) for j := 1; j < x; j++ { s := ps[i+j].Skill if s < min { min = s } if s > max { max = s } e += (ti-ps[i+j].Entered)*(x-1) } b := 200 - (max-min)*(max-min) if x > 2 { b *= x/2*3 } b -= e if b > bests { bestx,bests = x, b } } if bests > 0 { for j := 1; j < bestx; j++ { con = append(con, ps[i].Id, ps[i+j].Id) } copy(ps[i:],ps[i+bestx:]) ps = ps[:len(ps)-bestx] } } Println(len(con)/2) for i := 0; i < len(con); i += 2 { Println(con[i], con[i+1]) } } }