結果

問題 No.2453 Seat Allocation
ユーザー Challestend RehtorbegnaroChallestend Rehtorbegnaro
提出日時 2023-09-01 21:49:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 2,191 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 57,592 KB
実行使用メモリ 4,872 KB
最終ジャッジ日時 2023-09-07 15:34:55
合計ジャッジ時間 2,563 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 30 ms
4,848 KB
testcase_06 AC 10 ms
4,380 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 46 ms
4,872 KB
testcase_10 AC 43 ms
4,788 KB
testcase_11 AC 43 ms
4,832 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 14 ms
4,376 KB
testcase_14 AC 9 ms
4,380 KB
testcase_15 AC 19 ms
4,380 KB
testcase_16 AC 13 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 30 ms
4,380 KB
testcase_19 AC 36 ms
4,424 KB
testcase_20 AC 14 ms
4,380 KB
testcase_21 AC 19 ms
4,380 KB
testcase_22 AC 27 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <queue>
#define maxn 100000

namespace cltstream
{
	#define size 1048576
	char cltin[size + 1], *ih = cltin, *it = cltin;
	inline char gc()
	{
		#ifdef ONLINE_JUDGE
		if (ih == it)
		{
			it = (ih = cltin) + fread(cltin, 1, size, stdin);
			if (ih == it)
				return EOF;
		}
		return *ih++;
		#else
		return getchar();
		#endif
	}

	char cltout[size + 1], *oh = cltout, *ot = cltout + size;
	inline void pc(char c)
	{
		if (oh == ot)
		{
			fwrite(cltout, 1, size, stdout);
			oh = cltout;
		}
		*oh++ = c;
	}
	#define clop() fwrite(cltstream::cltout, 1, cltstream::oh - cltstream::cltout, stdout), cltstream::oh = cltstream::cltout
	#undef size

	template <typename _tp>
	inline void read(_tp& x)
	{
		char c = gc();
		for (; c != 45 && (c < 48 || c > 57) && c != EOF; c = gc());
		int sgn = c == 45 ? c = gc(), -1 : 1;
		for (x = 0; c >= 48 && c <= 57 && c != EOF; x = (x << 3) + (x << 1) + (c ^ 48), c = gc());
		x *= sgn;
	}

	template <typename _tp>
	inline void write(_tp x, char text = -1)
	{
		if (x < 0)
			pc(45), x = -x;
		if (!x)
			pc(48);
		else
		{
			int digit[22];
			for (digit[0] = 0; x; digit[++digit[0]] = x % 10, x /= 10);
			for (; digit[0]; pc(digit[digit[0]--] ^ 48));
		}
		if (text >= 0)
			pc(text);
	}

	inline void put(char str[], char text = -1)
	{
		for (int cur = 0; str[cur]; pc(str[cur++]));
		if (text >= 0)
			pc(text);
	}
}

int n, m;
int a[maxn + 5], b[maxn + 5];
struct node{ int x, y; };
std::priority_queue<node> heap;

inline bool operator<(const node &lhs, const node &rhs)
{
	long long L = 1LL * a[lhs.x] * b[rhs.y], R = 1LL * a[rhs.x] * b[lhs.y];
	if (L != R)
		return L < R;
	else
		return lhs.x > rhs.x;
}

int main()
{
	cltstream::read(n);
	cltstream::read(m);
	for (int i = 1; i <= n; ++i)
		cltstream::read(a[i]);
	for (int i = 1; i <= m; ++i)
		cltstream::read(b[i]);
	for (int i = 1; i <= n; ++i)
		heap.push({i, 1});
	for (int i = 1; i <= m; ++i)
	{
		node p = heap.top();
		heap.pop();
		if (p.y < m) heap.push({p.x, p.y + 1});
		cltstream::write(p.x, 10);
	}
	clop();
	return 0;
}
0