結果

問題 No.2453 Seat Allocation
ユーザー KumaTachiRenKumaTachiRen
提出日時 2023-09-01 22:05:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,540 bytes
コンパイル時間 4,356 ms
コンパイル使用メモリ 265,880 KB
実行使用メモリ 201,380 KB
最終ジャッジ日時 2023-09-01 22:05:35
合計ジャッジ時間 7,947 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 30 ms
6,976 KB
testcase_07 AC 104 ms
4,528 KB
testcase_08 AC 14 ms
4,380 KB
testcase_09 AC 186 ms
7,816 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 27 ms
7,272 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 105 ms
7,500 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 74 ms
7,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

struct Fast {
  Fast() {
    std::cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(10);
  }
} fast;

#define all(a) (a).begin(), (a).end()
#define contains(a, x) ((a).find(x) != (a).end())
#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (a); i--)
#define writejoin(s, a) rep(_i, 0, (a).size()) cout << (a)[_i] << (_i + 1 < (int)(a).size() ? s : "\n");
#define YN(b) cout << ((b) ? "YES" : "NO") << "\n";
#define Yn(b) cout << ((b) ? "Yes" : "No") << "\n";
#define yn(b) cout << ((b) ? "yes" : "no") << "\n";

using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n), b(m);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, m) cin >> b[i];

  double l = 1e-12, r = 1e9;
  while (abs(l - r) > 1e-9) {
    double x = (l + r) / 2;
    ll cnt = 0;
    rep(i, 0, n) {
      // b[j] <= a[i] / x
      auto it = upper_bound(all(b), a[i] / x);
      cnt += (it - b.begin());
    }
    if (cnt >= m)
      l = x;
    else
      r = x;
  }

  using P = pair<ll, ll>;
  using PP = pair<int, P>;
  vector<PP> ans;

  rep(i, 0, n) {
    rep(j, 0, m) {
      if (a[i] < l * b[j]) break;
      ans.push_back(PP(i + 1, P(a[i], b[j])));
    }
  }

  sort(all(ans), [&](const auto& x, const auto& y) {
    auto xp = x.second;
    auto yp = y.second;
    return xp.first * yp.second > yp.first * xp.second;
  });
  rep(i, 0, m) cout << ans[i].first << "\n";
}
0