結果

問題 No.801 エレベーター
ユーザー bal4ubal4u
提出日時 2019-07-17 07:02:06
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 948 bytes
コンパイル時間 806 ms
コンパイル使用メモリ 30,204 KB
実行使用メモリ 37,000 KB
最終ジャッジ日時 2023-08-22 14:32:36
合計ジャッジ時間 5,107 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 168 ms
36,980 KB
testcase_14 AC 167 ms
36,996 KB
testcase_15 AC 167 ms
36,896 KB
testcase_16 AC 167 ms
36,872 KB
testcase_17 AC 167 ms
36,920 KB
testcase_18 AC 167 ms
36,940 KB
testcase_19 AC 167 ms
36,896 KB
testcase_20 AC 167 ms
36,948 KB
testcase_21 AC 167 ms
36,964 KB
testcase_22 AC 167 ms
37,000 KB
testcase_23 AC 165 ms
36,884 KB
testcase_24 AC 166 ms
36,884 KB
testcase_25 AC 166 ms
36,868 KB
testcase_26 AC 166 ms
36,944 KB
testcase_27 AC 165 ms
36,836 KB
testcase_28 AC 166 ms
36,968 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘in’ 内:
main.c:7:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    7 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:12:24: 備考: in expansion of macro ‘gc’
   12 |         int n = 0, c = gc();
      |                        ^~

ソースコード

diff #

// yukicoder: No.801 エレベーター
// 2019.7.17 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

#define MOD 1000000007
int L[3003], R[3003];
int dp[3003][3003];

int main()
{
	int i, j, t, N, M, K, N1;
	
	N = in(), M = in(), K = in(), N1 = N+1;
	for (i = 0; i < M; i++) L[i] = in(), R[i] = in();

	dp[0][1] = 1;
	for (i = 0; i < K; i++) {
		for (j = 1; j <= N1; j++) dp[i][j] = (dp[i][j] + dp[i][j-1]) % MOD;

		for (j = 0; j < M; j++) if (dp[i][L[j]]) {
			t = (dp[i][R[j]] - dp[i][L[j]-1]) % MOD;
			dp[i+1][L[j]]   = (dp[i+1][L[j]]   + t) % MOD;
			dp[i+1][R[j]+1] = (dp[i+1][R[j]+1] - t) % MOD;
		}

		for (j = 1; j <= N1; j++) dp[i+1][j] = (dp[i+1][j] + dp[i+1][j-1]) % MOD;
    }
	if (dp[K][N] < 0) dp[K][N] += MOD;
	printf("%d\n", dp[K][N]);
	return 0;
}
0