結果

問題 No.801 エレベーター
ユーザー leaf_1415leaf_1415
提出日時 2019-03-17 22:08:56
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 333 ms
使用メモリ 73,956 KB
最終ジャッジ日時 2023-02-11 07:41:16
合計ジャッジ時間 5,336 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
4,908 KB
testcase_01 AC 1 ms
4,904 KB
testcase_02 AC 2 ms
4,904 KB
testcase_03 AC 5 ms
5,404 KB
testcase_04 AC 5 ms
5,392 KB
testcase_05 AC 5 ms
5,392 KB
testcase_06 AC 5 ms
5,276 KB
testcase_07 AC 5 ms
5,432 KB
testcase_08 AC 5 ms
5,408 KB
testcase_09 AC 5 ms
5,416 KB
testcase_10 AC 4 ms
5,316 KB
testcase_11 AC 4 ms
5,236 KB
testcase_12 AC 5 ms
5,308 KB
testcase_13 AC 230 ms
73,904 KB
testcase_14 AC 230 ms
73,948 KB
testcase_15 AC 230 ms
73,740 KB
testcase_16 AC 230 ms
73,836 KB
testcase_17 AC 230 ms
73,740 KB
testcase_18 AC 228 ms
73,812 KB
testcase_19 AC 230 ms
73,880 KB
testcase_20 AC 229 ms
73,752 KB
testcase_21 AC 229 ms
73,884 KB
testcase_22 AC 228 ms
73,956 KB
testcase_23 AC 221 ms
73,840 KB
testcase_24 AC 221 ms
73,732 KB
testcase_25 AC 224 ms
73,856 KB
testcase_26 AC 223 ms
73,872 KB
testcase_27 AC 221 ms
73,664 KB
testcase_28 AC 225 ms
73,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#define llint long long
#define mod 1000000007

using namespace std;


llint n, m, k;
llint l[3005], r[3005];
llint dp[3005][3005];
llint sum[3005];

int main(void)
{
	cin >> n >> m >> k;
	for(int i = 0; i < m; i++) cin >> l[i] >> r[i];
	
	dp[0][1] = 1;
	for(int i = 1; i <= k; i++){
		for(int j = 1; j <= n; j++){
			sum[j] = sum[j-1] + dp[i-1][j];
			sum[j] %= mod;
		}
		for(int j = 0; j < m; j++){
			dp[i][l[j]] += (sum[r[j]] - sum[l[j]-1]) % mod, dp[i][l[j]] %= mod;
			dp[i][r[j]+1] += (mod - (sum[r[j]] - sum[l[j]-1]) % mod) % mod, dp[i][r[j]+1] %= mod;
		}
		for(int j = 1; j <= n; j++){
			dp[i][j] += dp[i][j-1];
			dp[i][j] %= mod;
		}
	}
	cout << dp[k][n] << endl;
	
	return 0;
}
0