結果

問題 No.801 エレベーター
ユーザー misora192misora192
提出日時 2020-05-21 09:04:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 902 bytes
コンパイル時間 1,696 ms
コンパイル使用メモリ 168,128 KB
実行使用メモリ 74,080 KB
最終ジャッジ日時 2024-04-09 23:15:24
合計ジャッジ時間 4,479 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
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 WA -
testcase_28 AC 121 ms
73,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll n, m, k;
	cin >> n >> m >> k;

	vector<ll> l(m), r(m);
	rep(i, m){
		cin >> l[i] >> r[i];
		l[i]--;
		r[i]--;
	} 

	ll MOD = 1e9 + 7;
	ll dp[k+1][n+1];
	rep(i, k+1) rep(j, n+1) dp[i][j] = 0;
	dp[0][0] = 1;

	rep(i, k){
		vector<ll> a(n+1, 0);
		rep(j, n) {
			a[j+1] = a[j] + dp[i][j];
			a[j+1] %= MOD;
		}

		rep(j, m){
			ll sm = a[r[j]+1] - a[l[j]];
			dp[i+1][l[j]] += sm;
			dp[i+1][l[j]] %= MOD;
			dp[i+1][r[j]+1] += MOD - sm;
			dp[i+1][r[j]+1] %= MOD;
		}

		rep(j, n){
			dp[i+1][j+1] += dp[i+1][j];
		}
	}

	cout << dp[k][n-1] << endl;
}
0