結果

問題 No.2453 Seat Allocation
ユーザー simansiman
提出日時 2023-09-03 02:12:28
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,208 bytes
コンパイル時間 1,222 ms
コンパイル使用メモリ 103,992 KB
実行使用メモリ 6,136 KB
最終ジャッジ日時 2023-09-03 02:12:59
合計ジャッジ時間 5,324 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 220 ms
6,028 KB
testcase_06 RE -
testcase_07 AC 36 ms
5,940 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
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 WA -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 1 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;

  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;
  }

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

  return 0;
}
0