結果

問題 No.2453 Seat Allocation
ユーザー tnakao0123tnakao0123
提出日時 2023-09-11 15:15:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 982 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 56,020 KB
実行使用メモリ 5,480 KB
最終ジャッジ日時 2023-09-11 15:15:37
合計ジャッジ時間 4,525 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 51 ms
5,400 KB
testcase_06 AC 25 ms
4,380 KB
testcase_07 AC 16 ms
5,092 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 59 ms
5,480 KB
testcase_10 AC 58 ms
5,464 KB
testcase_11 AC 57 ms
5,456 KB
testcase_12 AC 24 ms
4,380 KB
testcase_13 AC 29 ms
4,376 KB
testcase_14 AC 24 ms
4,380 KB
testcase_15 AC 33 ms
4,380 KB
testcase_16 AC 27 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 41 ms
4,380 KB
testcase_19 AC 49 ms
5,332 KB
testcase_20 AC 21 ms
4,376 KB
testcase_21 AC 26 ms
4,380 KB
testcase_22 AC 38 ms
4,380 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2453.cc:  No.2453 Seat Allocation - yukicoder
 */

#include<cstdio>
#include<queue>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_M = 100000;

/* typedef */

struct Cand {
  double s;
  int i, j;
  Cand() {}
  Cand(double _s, int _i, int _j): s(_s), i(_i), j(_j) {}

  bool operator<(const Cand &c) const {
    return s < c.s || (s == c.s && i > c.i);
  }
};

/* global variables */

int as[MAX_N], bs[MAX_M];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", as + i);
  for (int i = 0; i < m; i++) scanf("%d", bs + i);

  priority_queue<Cand> q;
  for (int i = 0; i < n; i++)
    q.push(Cand((double)as[i] / bs[0], i, 0));

  for (int k = 0; k < m; k++) {
    auto u = q.top(); q.pop();
    printf("%d\n", u.i + 1);

    if (u.j + 1 < m)
      q.push(Cand((double)as[u.i] / bs[u.j + 1], u.i, u.j + 1));
  }

  return 0;
}
0