結果

問題 No.2453 Seat Allocation
ユーザー simansiman
提出日時 2023-09-03 02:14:22
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,155 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 105,284 KB
実行使用メモリ 8,400 KB
最終ジャッジ日時 2023-09-03 02:14:48
合計ジャッジ時間 5,271 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 229 ms
7,052 KB
testcase_06 RE -
testcase_07 AC 35 ms
7,028 KB
testcase_08 AC 20 ms
4,380 KB
testcase_09 AC 238 ms
7,060 KB
testcase_10 AC 229 ms
7,076 KB
testcase_11 AC 235 ms
7,896 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 74 ms
5,072 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 1 ms
4,388 KB
testcase_24 AC 2 ms
4,380 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;
  ll a;
  ll b;

  Node(int i = -1, ll a = 0, ll b = 0) {
    this->i = i;
    this->a = a;
    this->b = b;
  }

  bool operator>(const Node &n) const {
    ll v1 = a * n.b;
    ll v2 = n.a * b;

    if (v1 == v2) {
      return i > n.i;
    } else {
      return v1 < v2;
    }
  }
};

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, 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]];
      pque.push(node);
    }
  }

  return 0;
}
0