結果

問題 No.750 Frac #1
ユーザー claw88
提出日時 2018-11-09 21:22:04
言語 C#
(csc 3.4.0-beta4-19569-03)
結果
AC  
実行時間 32 ms
コード長 2,617 Byte
コンパイル時間 4,592 ms
使用メモリ 19,344 KB
最終ジャッジ日時 2020-01-01 03:58:49

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
sample_01 AC 28 ms
19,192 KB
sample_02 AC 32 ms
19,068 KB
sample_03 AC 28 ms
19,124 KB
test_01 AC 32 ms
19,108 KB
test_02 AC 32 ms
19,196 KB
test_03 AC 28 ms
19,276 KB
test_04 AC 28 ms
19,120 KB
test_05 AC 32 ms
19,244 KB
test_06 AC 28 ms
18,908 KB
test_07 AC 28 ms
19,096 KB
test_08 AC 32 ms
19,144 KB
test_09 AC 28 ms
19,272 KB
test_10 AC 28 ms
19,152 KB
test_11 AC 32 ms
19,312 KB
test_12 AC 28 ms
19,020 KB
test_13 AC 28 ms
18,908 KB
test_14 AC 28 ms
19,152 KB
test_15 AC 32 ms
19,192 KB
test_16 AC 28 ms
19,032 KB
test_17 AC 32 ms
19,192 KB
test_18 AC 28 ms
18,936 KB
test_19 AC 32 ms
19,136 KB
test_20 AC 28 ms
19,128 KB
test_21 AC 28 ms
19,264 KB
test_22 AC 32 ms
19,156 KB
test_23 AC 28 ms
19,196 KB
test_24 AC 28 ms
19,136 KB
test_25 AC 32 ms
19,196 KB
test_26 AC 28 ms
18,936 KB
test_27 AC 32 ms
19,200 KB
test_28 AC 28 ms
19,140 KB
test_29 AC 28 ms
19,344 KB
test_30 AC 32 ms
19,108 KB
テストケース一括ダウンロード
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.4.0-beta4-19569-03 (82f2e254)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        var P = new pair[N];
        for (int i = 0; i < N; i++)
        {
            P[i] = new pair(cin.nextint, cin.nextint);
        }
        P = P.OrderByDescending(i => (double)i.f / i.s).ToArray();
        foreach (var item in P)
        {
            WriteLine(item);
        }
    }

}


class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
    public T f;
    public U s;
    public Pair(T f, U s)
    {
        this.f = f;
        this.s = s;
    }
    public int CompareTo(Pair<T, U> a)
    {
        return f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);
    }
    public override string ToString()
    {
        return f + " " + s;
    }
}
class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}
0