結果

問題 No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
ユーザー pengin_2000pengin_2000
提出日時 2022-08-23 13:08:32
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 1,397 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 31,616 KB
実行使用メモリ 8,308 KB
最終ジャッジ日時 2024-04-19 03:55:25
合計ジャッジ時間 8,915 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 52 ms
5,376 KB
testcase_17 AC 90 ms
7,808 KB
testcase_18 AC 48 ms
6,400 KB
testcase_19 AC 26 ms
5,376 KB
testcase_20 AC 32 ms
5,376 KB
testcase_21 AC 99 ms
8,304 KB
testcase_22 AC 69 ms
8,192 KB
testcase_23 AC 103 ms
8,192 KB
testcase_24 AC 79 ms
8,176 KB
testcase_25 AC 76 ms
8,136 KB
testcase_26 AC 100 ms
8,148 KB
testcase_27 AC 100 ms
8,180 KB
testcase_28 AC 79 ms
8,172 KB
testcase_29 AC 100 ms
8,308 KB
testcase_30 AC 103 ms
8,180 KB
testcase_31 AC 64 ms
8,304 KB
testcase_32 AC 72 ms
8,304 KB
testcase_33 AC 71 ms
8,172 KB
testcase_34 AC 77 ms
8,304 KB
testcase_35 AC 73 ms
8,192 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
long long int d[200005];
long long int h[200005], l;
int comp_h(long long int a, long long int b)
{
	if (d[h[a]] < d[h[b]])
		return 1;
	else
		return -1;
}
void swap_h(long long int a, long long int b)
{
	long long int f = h[a];
	h[a] = h[b];
	h[b] = f;
	return;
}
void push(long long int ne)
{
	h[l] = ne;
	long long int p = l;
	l++;
	for (; p > 0; p = (p - 1) / 2)
		if (comp_h((p - 1) / 2, p) > 0)
			swap_h((p - 1) / 2, p);
	return;
}
long long int pop()
{
	l--;
	swap_h(0, l);
	long long int p = 0;
	for (;;)
	{
		if (2 * p + 2 < l)
		{
			if (comp_h(2 * p + 1, 2 * p + 2) > 0)
			{
				if (comp_h(p, 2 * p + 2) > 0)
					swap_h(p, 2 * p + 2);
				p = 2 * p + 2;
			}
			else
			{
				if (comp_h(p, 2 * p + 1) > 0)
					swap_h(p, 2 * p + 1);
				p = 2 * p + 1;
			}
		}
		else if (2 * p + 1 < l)
		{
			if (comp_h(p, 2 * p + 1) > 0)
				swap_h(p, 2 * p + 1);
			p = 2 * p + 1;
		}
		else
			break;
	}
	return h[l];
}
long long int a[200005], b[200005];
char ans[200005];
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int i;
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	for (i = 0; i < n; i++)
		scanf("%lld", &b[i]);
	for (i = 0; i < n; i++)
		d[i] = a[i] - b[i];
	l = 0;
	for (i = 0; i < n; i++)
		push(i);
	for (i = 0; i < n; i++)
		ans[i] = 'B';
	for (i = 0; i < k; i++)
		ans[pop()]--;
	ans[n] = '\0';
	printf("%s\n", ans);
	return 0;
}
0