結果

問題 No.2453 Seat Allocation
ユーザー simansiman
提出日時 2023-09-03 02:07:07
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,270 bytes
コンパイル時間 7,606 ms
コンパイル使用メモリ 104,716 KB
実行使用メモリ 7,120 KB
最終ジャッジ日時 2023-09-03 02:07:56
合計ジャッジ時間 9,556 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 252 ms
7,100 KB
testcase_06 RE -
testcase_07 AC 37 ms
7,020 KB
testcase_08 AC 20 ms
4,380 KB
testcase_09 AC 254 ms
7,120 KB
testcase_10 AC 230 ms
7,012 KB
testcase_11 AC 230 ms
7,008 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 80 ms
5,132 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 WA -
testcase_24 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

struct Node {
  int i;
  int cnt;
  int a;
  int b;
  double value;

  Node(int i = -1, int cnt = -1, int a = 0, int b = 0) {
    this->i = i;
    this->cnt = cnt;
    this->a = a;
    this->b = b;
    this->value = a * 1.0 / b;
  }

  bool operator>(const Node &n) const {
    if (value == n.value) {
      return i > n.i;
    } else {
      return value < n.value;
    }
  }
};

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  vector<int> B(N);
  for (int i = 0; i < M; ++i) {
    cin >> B[i];
  }

  priority_queue <Node, vector<Node>, greater<Node>> pque;
  for (int i = 0; i < N; ++i) {
    pque.push(Node(i, 1, A[i], B[0]));
  }

  vector<int> counter(N, 0);

  for (int i = 0; i < M; ++i) {
    Node node = pque.top();
    pque.pop();

    cout << node.i + 1 << endl;
    counter[node.i]++;

    if (counter[node.i] < M) {
      node.b = B[counter[node.i]];
      node.value = node.a * 1.0 / node.b;
      pque.push(node);
    }
  }

  return 0;
}
0