結果

問題 No.750 Frac #1
コンテスト
ユーザー ゆうP
提出日時 2024-05-04 20:07:13
言語 Go
(1.26.1)
コンパイル:
env GOCACHE=/tmp go build _filename_
実行:
./Main
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 501 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 11,873 ms
コンパイル使用メモリ 277,188 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-20 20:27:25
合計ジャッジ時間 13,118 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// 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