結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー bal4ubal4u
提出日時 2019-12-12 21:55:52
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,226 bytes
コンパイル時間 1,148 ms
コンパイル使用メモリ 29,460 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-08 00:38:29
合計ジャッジ時間 2,060 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 WA -
testcase_26 AC 1 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 1 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1 ms
4,384 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// yuki 949 飲酒プログラミングコンテスト
// 2019.12.12 bal4u

#include <stdio.h>
#include <ctype.h>

int getchar_unlocked(void);
#define gc() getchar_unlocked()

int in() {  // 整数の入力
	int n = 0; int c;
	do c = gc();
	while (isspace(c));
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void Qsort(int *a, int l, int r) {
	int i, j, m, t;
	
	i = l, j = r, m = a[(l+r) >> 1];
	while (1) {
		while (a[i] < m) i++;
		while (m < a[j]) j--;
		if (i >= j)	break;
		t = a[i], a[i] = a[j], a[j] = t;
		i++, j--;
	}
	if (l+1 < i) Qsort(a, l, i-1);
	if (j+1 < r) Qsort(a, j+1, r);
}

int N;
int A[3005], B[3005];
int D[3005];

int main()
{
	int i, j, a, b, s, ans;
	
	N = in();
	for (i = 0; i <= N; ++i) A[i] = in();
	for (i = 0; i <= N; ++i) B[i] = in();
	for (i = 1; i <= N; ++i) D[i] = in();
	Qsort(D, 1, N), D[0] = -200005;
	j = N;
	
	a = b = 0, ans = 0, A[N+1] = B[N+1] = -100002;
	while (ans < N && a <= N && b <= N) {
		if (A[a]+B[b+1] >= A[a+1]+B[b]) s = A[a]+B[++b];
		else s = A[++a]+B[b];
		while (s < D[j]) --j;
		if (j == 0) break;
		++ans, --j;
	}
	printf("%d\n", ans);
	return 0;
}
0