結果
問題 | No.570 3人兄弟(その1) |
ユーザー |
![]() |
提出日時 | 2017-10-14 19:46:34 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 954 bytes |
コンパイル時間 | 14,331 ms |
コンパイル使用メモリ | 224,792 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 14:51:09 |
合計ジャッジ時間 | 14,827 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 5 |
ソースコード
package mainimport ("fmt""bufio""os""strconv""sort")var sc = bufio.NewScanner(os.Stdin)func nextLine() string {sc.Scan()return sc.Text()}func nextInt() int {sc.Scan()i, e := strconv.Atoi(sc.Text())if e != nil {panic(e)}return i}func main() {numDict := map[string]int{}numDict["A"] = nextInt()numDict["B"] = nextInt()numDict["C"] = nextInt()a := List{}for k, v := range numDict {e := Entry{k, v}a = append(a, e)}sort.Sort(a)for _, e := range a {fmt.Println(e.name)}}type Entry struct {name stringvalue int}type List []Entryfunc (l List) Len() int {return len(l)}func (l List) Swap(i, j int) {l[i], l[j] = l[j], l[i]}func (l List) Less(i, j int) bool {// 値が等しい場合はキーで昇順にソートif l[i].value == l[j].value {return (l[i].name < l[j].name)} else {return (l[i].value > l[j].value)}}