結果

問題 No.1043 直列大学
ユーザー bal4ubal4u
提出日時 2021-08-12 12:05:17
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 1,105 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 29,912 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-24 12:57:22
合計ジャッジ時間 1,974 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 0 ms
4,380 KB
testcase_06 AC 0 ms
4,384 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 15 ms
4,384 KB
testcase_12 AC 25 ms
4,384 KB
testcase_13 AC 17 ms
4,384 KB
testcase_14 AC 19 ms
4,384 KB
testcase_15 AC 23 ms
4,384 KB
testcase_16 AC 19 ms
4,380 KB
testcase_17 AC 11 ms
4,508 KB
testcase_18 AC 11 ms
4,384 KB
testcase_19 AC 17 ms
4,380 KB
testcase_20 AC 10 ms
4,384 KB
testcase_21 AC 15 ms
4,380 KB
testcase_22 AC 16 ms
4,380 KB
testcase_23 AC 24 ms
4,384 KB
testcase_24 AC 12 ms
4,380 KB
testcase_25 AC 17 ms
4,380 KB
testcase_26 AC 19 ms
4,384 KB
testcase_27 AC 6 ms
4,380 KB
testcase_28 AC 14 ms
4,380 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 13 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘in’ 内:
main.c:6:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    6 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:10:28: 備考: in expansion of macro ‘gc’
   10 |         int n = 0; int c = gc();
      |                            ^~

ソースコード

diff #

// yuki 1043 直列大学
// 2021.8.12

#include <stdio.h>

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

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

typedef long long ll;
const int mod = 1e9+7;
int V[105], vdp[100005]; int N;
int R[105], rdp[100005]; int M;
int s[100005];

void cal_dp(int *a, int w, int *dp, int ma) {
	int i, j;
	dp[0] = 1;
	for (i = 0; i < w; ++i) {
		for (j = ma; j >= 0; --j) if (dp[j])
			dp[j+a[i]] = ((ll)dp[j+a[i]] + dp[j]) % mod;
	}
}

int main()
{
	int i, vma, rma;
	ll ans, A, B, k;

	N = in(), M = in(), vma = N*1000, rma = M*1000;
	for (i = 0; i < N; ++i) V[i] = in();
	cal_dp(V, N, vdp, vma);
	for (i = 1; i <= vma; ++i) 
		s[i] = (s[i-1]+vdp[i]) % mod;
	for (i = 0; i < M; ++i) R[i] = in();
	cal_dp(R, M, rdp, rma);

	A = in(), B = in();
	ans = 0;
	for (i = 1; i <= rma && i*A <= vma; ++i) if (rdp[i]) {
		if ((k = i*B) > vma) k = vma;
		ans += (ll)rdp[i] * (s[k]-s[i*A-1]) % mod;
	}
	ans %= mod; if (ans < 0) ans += mod;
	printf("%d\n", (int)ans);
	return 0;
}
0