結果

問題 No.2453 Seat Allocation
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-09-01 22:07:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 719 bytes
コンパイル時間 2,214 ms
コンパイル使用メモリ 205,696 KB
実行使用メモリ 6,244 KB
最終ジャッジ日時 2023-09-07 15:35:26
合計ジャッジ時間 6,665 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 237 ms
6,232 KB
testcase_06 AC 171 ms
4,376 KB
testcase_07 AC 35 ms
5,532 KB
testcase_08 AC 21 ms
4,376 KB
testcase_09 AC 272 ms
6,232 KB
testcase_10 AC 272 ms
6,232 KB
testcase_11 AC 279 ms
6,244 KB
testcase_12 AC 172 ms
4,384 KB
testcase_13 AC 177 ms
4,376 KB
testcase_14 AC 169 ms
4,376 KB
testcase_15 AC 182 ms
4,380 KB
testcase_16 AC 167 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 200 ms
4,944 KB
testcase_19 AC 235 ms
6,004 KB
testcase_20 AC 87 ms
4,548 KB
testcase_21 AC 133 ms
4,380 KB
testcase_22 AC 190 ms
4,596 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using T = tuple<int, int, int>;
ll A[200020], B[200020];
int main () {
	int N, M;
	cin >> N >> M;
	for (int i = 1; i <= N; i ++) {
		cin >> A[i];
	}
	for (int i = 0; i < M; i ++) {
		cin >> B[i];
	}
	auto cmp = [&] (T b, T a) {
	auto& [a1, a2, a3] = a;
	auto& [b1, b2, b3] = b;
	if (A[a1] * B[b2] != B[a2] * A[b1]) {
		return A[a1] * B[b2] > B[a2] * A[b1];
	} else {
		return a3 < b3;
	}
};
	priority_queue<T, std::vector<T>, decltype(cmp)> pque{cmp};
	for (int i = 1; i <= N; i ++) {
		pque.emplace(i, 0, i);
	}
	for (int i = 0; i < M; i ++) {
		auto [a1, a2, a3] = pque.top();
		pque.pop();
		cout << a1 << endl;
		pque.emplace(a1, a2 + 1, a3);
	}
}
0