結果

問題 No.750 Frac #1
ユーザー ooaiu
提出日時 2024-12-15 18:39:44
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 674 bytes
コンパイル時間 3,753 ms
コンパイル使用メモリ 250,556 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-15 18:39:50
合計ジャッジ時間 4,226 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef LOCAL
#include <bits/stdc++.h>

using namespace std;

#define debug(...) (void(0))
#else
#include "algo/debug.h"
#endif

void solve() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
    vector<int> ord(N);
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(), [&](int i, int j) -> bool {
        return A[i] * B[j] > A[j] * B[i];
    });
    for(int i = 0; i < N; i++) {
        cout << A[ord[i]] << " " << B[ord[i]] << '\n';
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int tt = 1;
    // std::cin >> tt;
    while (tt--) {
        solve();
    }
}
0