結果
問題 |
No.2453 Seat Allocation
|
ユーザー |
![]() |
提出日時 | 2023-09-03 02:07:07 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,270 bytes |
コンパイル時間 | 3,032 ms |
コンパイル使用メモリ | 142,284 KB |
実行使用メモリ | 7,268 KB |
最終ジャッジ日時 | 2024-06-12 07:18:53 |
合計ジャッジ時間 | 8,383 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 1 RE * 11 |
ソースコード
#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; }