結果
問題 | No.571 3人兄弟(その2) |
ユーザー |
![]() |
提出日時 | 2018-05-20 16:50:59 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 954 bytes |
コンパイル時間 | 11,215 ms |
コンパイル使用メモリ | 240,708 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 14:43:08 |
合計ジャッジ時間 | 11,879 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
package main import ( "bufio" "fmt" "os" "sort" "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() } // Person ... type Person struct { H int W int Name string } // People ... type People []Person func (a People) Len() int { return len(a) } func (a People) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a People) Less(i, j int) bool { if a[i].H == a[j].H { return a[i].W < a[j].W } return a[i].H > a[j].H } func main() { var vs People alphas := []string{"A", "B", "C"} for i := 0; i < 3; i++ { c := strings.Split(nextLine(), " ") x, _ := strconv.Atoi(c[0]) y, _ := strconv.Atoi(c[1]) vs = append(vs, Person{ H: x, W: y, Name: alphas[i], }) } sort.Sort(People(vs)) for _, p := range vs { fmt.Println(p.Name) } }