結果

問題 No.750 Frac #1
ユーザー merom686
提出日時 2018-11-16 15:03:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 600 bytes
コンパイル時間 733 ms
コンパイル使用メモリ 79,464 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 14:10:09
合計ジャッジ時間 2,003 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P& p) const {
        return (double)a / b > (double)p.a / p.b;
    }
    int a, b;
};

int main() {
    int n;
    cin >> n;

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        p[i] = { a, b };
    }
    sort(p.begin(), p.end());

    for (int i = 0; i < n; i++) {
        cout << p[i].a << ' ' << p[i].b << endl;
    }

    return 0;
}
0