結果

問題 No.801 エレベーター
ユーザー ats5515ats5515
提出日時 2019-03-17 23:05:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 464 ms / 2,000 ms
コード長 956 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 79,192 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 09:47:23
合計ジャッジ時間 9,062 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 6 ms
4,376 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 457 ms
4,376 KB
testcase_14 AC 457 ms
4,376 KB
testcase_15 AC 456 ms
4,376 KB
testcase_16 AC 457 ms
4,376 KB
testcase_17 AC 457 ms
4,376 KB
testcase_18 AC 457 ms
4,380 KB
testcase_19 AC 457 ms
4,376 KB
testcase_20 AC 457 ms
4,380 KB
testcase_21 AC 458 ms
4,376 KB
testcase_22 AC 458 ms
4,376 KB
testcase_23 AC 464 ms
4,380 KB
testcase_24 AC 464 ms
4,380 KB
testcase_25 AC 462 ms
4,380 KB
testcase_26 AC 464 ms
4,376 KB
testcase_27 AC 461 ms
4,376 KB
testcase_28 AC 462 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, K;
	cin >> N >> M >> K;
	vector<int> L(M);
	vector<int> R(M);
	for (int i = 0; i < M; i++) {
		cin >> L[i] >> R[i];
	}
	vector<int> dp(N + 2, 0);
	dp[1] = 1;

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


		vector<int> ndp(N + 2, 0);
		for (int j = 0; j < M; j++) {
			int sum = dp[R[j]] - dp[L[j] - 1];
			if (sum < 0)sum += MOD;
			ndp[L[j]] = (ndp[L[j]] + sum) % MOD;
			ndp[R[j] + 1] -= sum; 
			if (ndp[R[j] + 1] < 0)ndp[R[j] + 1] += MOD;
		}
		for (int j = 1; j <= N + 1; j++) {
			ndp[j] = (ndp[j] + ndp[j - 1]) % MOD;
		}
		swap(dp, ndp);
	}

	cout << dp[N] << endl;
}
0