結果
問題 |
No.750 Frac #1
|
ユーザー |
![]() |
提出日時 | 2019-09-06 19:32:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 550 bytes |
コンパイル時間 | 723 ms |
コンパイル使用メモリ | 61,732 KB |
最終ジャッジ日時 | 2025-01-07 16:38:42 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%zu", &n); | ~~~~~^~~~~~~~~~~ main.cpp:12:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | for (auto& p: ab) scanf("%d %d", &p.first, &p.second); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <vector> #include <algorithm> #include <utility> #include <tuple> int main() { size_t n; scanf("%zu", &n); std::vector<std::pair<int, int>> ab(n); for (auto& p: ab) scanf("%d %d", &p.first, &p.second); std::sort(ab.begin(), ab.end(), [](auto const& p1, auto const& p2) { int a1, a2, b1, b2; std::tie(a1, b1) = p1; std::tie(a2, b2) = p2; return a1*b2 > a2*b1; }); for (auto const& p: ab) printf("%d %d\n", p.first, p.second); }