結果

問題 No.2453 Seat Allocation
ユーザー KumaTachiRenKumaTachiRen
提出日時 2023-09-01 22:19:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 1,390 bytes
コンパイル時間 4,221 ms
コンパイル使用メモリ 266,372 KB
実行使用メモリ 9,076 KB
最終ジャッジ日時 2023-09-07 15:35:48
合計ジャッジ時間 8,158 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 187 ms
7,904 KB
testcase_06 AC 149 ms
4,376 KB
testcase_07 AC 29 ms
7,296 KB
testcase_08 AC 19 ms
4,376 KB
testcase_09 AC 207 ms
9,012 KB
testcase_10 AC 208 ms
9,076 KB
testcase_11 AC 205 ms
7,744 KB
testcase_12 AC 150 ms
4,376 KB
testcase_13 AC 154 ms
4,380 KB
testcase_14 AC 147 ms
4,376 KB
testcase_15 AC 165 ms
4,380 KB
testcase_16 AC 152 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 157 ms
5,756 KB
testcase_19 AC 176 ms
7,460 KB
testcase_20 AC 69 ms
5,472 KB
testcase_21 AC 113 ms
4,380 KB
testcase_22 AC 163 ms
5,040 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 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];

  using P = pair<int, int>;
  using PL = pair<ll, ll>;
  using PP = pair<P, PL>;
  priority_queue<PP, vector<PP>, function<bool(PP, PP)>> pq([](PP x, PP y) {
    ll v = x.second.first * y.second.second - y.second.first * x.second.second;
    return v != 0 ? v < 0 : x.first.first > y.first.first;
  });
  rep(i, 0, n) pq.push(PP(P(i, 0), PL(a[i], b[0])));

  rep(k, 0, m) {
    auto p = pq.top();
    pq.pop();
    auto q = p.first;
    cout << (q.first + 1) << endl;
    pq.push(PP(P(q.first, q.second + 1), PL(a[q.first], b[q.second + 1])));
  }
}
0