結果

問題 No.1043 直列大学
ユーザー bal4ubal4u
提出日時 2021-08-12 11:09:22
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,243 bytes
コンパイル時間 1,926 ms
コンパイル使用メモリ 31,232 KB
実行使用メモリ 6,952 KB
最終ジャッジ日時 2024-04-09 02:27:50
合計ジャッジ時間 3,336 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,820 KB
testcase_01 AC 1 ms
6,948 KB
testcase_02 AC 1 ms
6,948 KB
testcase_03 AC 1 ms
6,948 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,948 KB
testcase_06 AC 1 ms
6,948 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,952 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 22 ms
6,944 KB
testcase_15 AC 25 ms
6,948 KB
testcase_16 AC 21 ms
6,948 KB
testcase_17 AC 12 ms
6,944 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 7 ms
6,948 KB
testcase_28 WA -
testcase_29 AC 3 ms
6,948 KB
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'in':
main.c:6:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
    6 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:10:28: note: 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]] += dp[j];
	}
}

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

	N = in(), M = in();
	for (i = 0; i < N; ++i) V[i] = in();
	cal_dp(V, N, vdp, N*1000);
	for (i = 0; i < M; ++i) R[i] = in();
	cal_dp(R, M, rdp, M*1000);
	for (i = 1; i <= M*1000; ++i) 
		s[i] = (s[i-1]+rdp[i]) % mod;
/*
for (i = 0; i <= 20; ++i) if (vdp[i]) printf("(%d,%d) ", i, vdp[i]);
printf("\n");
for (i = 0; i <= 20; ++i) if (rdp[i]) printf("(%d,%d) ", i, rdp[i]);
printf("\n");
for (i = 0; i <= 20; ++i) printf("%d ", s[i]);
printf("\n");
*/

	A = in(), B = in();
	ans = 0;
	for (i = 1; i <= N*1000; ++i) if (vdp[i]) {
		ans += (ll)vdp[i] * (s[i/A]-s[(i-1)/B]) % mod;
	}
	ans %= mod; if (ans < 0) ans += mod;
	printf("%d\n", (int)ans);
	return 0;
}
0