結果

問題 No.750 Frac #1
ユーザー ゆうP
提出日時 2024-05-04 20:07:13
言語 Go
(1.23.4)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 501 bytes
コンパイル時間 12,790 ms
コンパイル使用メモリ 222,560 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-26 10:17:09
合計ジャッジ時間 11,801 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.750 Frac #1
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	type target struct {
		molecule    int
		denominator int
		decimal     float64
	}
	t := make([]target, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&t[i].molecule, &t[i].denominator)
		t[i].decimal = float64(t[i].molecule) / float64(t[i].denominator)
	}

	sort.Slice(t, func(i, j int) bool {
		return t[i].decimal > t[j].decimal
	})

	for _, tt := range t {
		fmt.Println(tt.molecule, tt.denominator)
	}
}
0