結果

問題 No.801 エレベーター
ユーザー e869120e869120
提出日時 2019-05-15 21:22:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 64,944 KB
実行使用メモリ 74,052 KB
最終ジャッジ日時 2023-10-12 14:29:19
合計ジャッジ時間 3,850 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 4 ms
10,020 KB
testcase_04 AC 5 ms
10,112 KB
testcase_05 AC 5 ms
10,056 KB
testcase_06 AC 4 ms
10,116 KB
testcase_07 AC 4 ms
10,176 KB
testcase_08 AC 4 ms
10,032 KB
testcase_09 AC 5 ms
10,180 KB
testcase_10 AC 5 ms
10,172 KB
testcase_11 AC 5 ms
10,268 KB
testcase_12 AC 4 ms
10,020 KB
testcase_13 AC 138 ms
73,888 KB
testcase_14 AC 134 ms
73,936 KB
testcase_15 AC 134 ms
73,756 KB
testcase_16 AC 133 ms
73,764 KB
testcase_17 AC 134 ms
73,760 KB
testcase_18 AC 133 ms
74,012 KB
testcase_19 AC 133 ms
73,876 KB
testcase_20 AC 134 ms
73,884 KB
testcase_21 AC 139 ms
73,988 KB
testcase_22 AC 134 ms
74,052 KB
testcase_23 AC 128 ms
73,860 KB
testcase_24 AC 127 ms
73,788 KB
testcase_25 AC 127 ms
73,860 KB
testcase_26 AC 129 ms
73,880 KB
testcase_27 AC 128 ms
73,696 KB
testcase_28 AC 129 ms
73,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

const long long mod = 1000000007;
long long N, M, K, L[3009], R[3009], dp[3009][3009];

int main() {
	cin >> N >> M >> K;
	for (int i = 1; i <= M; i++) cin >> L[i] >> R[i];

	for (int i = 1; i <= N; i++) dp[0][i] = 1;
	for (int i = 0; i < K; i++) {
		for (int j = 1; j <= M; j++) {
			long long E = dp[i][R[j]] - dp[i][L[j] - 1] + mod; E %= mod;
			dp[i + 1][L[j]] += E;
			dp[i + 1][R[j] + 1] -= E;
		}
		for (int j = 1; j <= N; j++) { dp[i + 1][j] += dp[i + 1][j - 1]; dp[i + 1][j] %= mod; }
		for (int j = 1; j <= N; j++) { dp[i + 1][j] += dp[i + 1][j - 1]; dp[i + 1][j] %= mod; }
	}
	cout << (dp[K][N] - dp[K][N - 1] + mod) % mod << endl;
	return 0;
}
0