結果
| 問題 |
No.801 エレベーター
|
| コンテスト | |
| ユーザー |
peroon
|
| 提出日時 | 2019-03-18 01:40:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 150 ms / 2,000 ms |
| コード長 | 2,598 bytes |
| コンパイル時間 | 916 ms |
| コンパイル使用メモリ | 99,848 KB |
| 実行使用メモリ | 74,240 KB |
| 最終ジャッジ日時 | 2024-07-08 07:59:53 |
| 合計ジャッジ時間 | 4,334 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
const ll mod = 1e9 + 7;
const ll inf = 1e18;
ofstream of;
template < typename T >
void vprint(T &V){
for(auto v : V){
cout << v << " ";
}
cout << endl;
}
// k回目のl階
ll dp[3010][3010] = {};
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// input
ll N, M, K;
cin >> N >> M >> K;
// 一応
FOR(i, 0, 3010){
FOR(j, 0, 3010){
dp[i][j] = 0;
}
}
// of.open("log.txt");
vector<ll> L(M);
vector<ll> R(M);
FOR(i, 0, M){
ll l, r;
cin >> l >> r;
L[i] = l;
R[i] = r;
}
// k = 0
dp[0][1] = 1;
FOR(i, 2, N+1){
dp[0][i] = 0;
}
FOR(k, 1, K+1){
// of << endl;
// of << "k " << k << endl;
// 累積和
ll Ac[3010];
Ac[0] = 0;
FOR(i, 1, N+1){
Ac[i] = dp[k-1][i];
}
// 累積
FOR(i, 1, N+1){
Ac[i] += Ac[i-1];
}
// FOR(i, 1, N+1){
// cout << Ac[i] << " ";
// }
// 各エレベーターについて
FOR(i, 0, M){
ll l = L[i];
ll r = R[i];
ll sum = Ac[r] - Ac[l-1];
// pn(sum);
dp[k][l] += sum;
// dp[k][l] %= mod;
dp[k][r+1] -= sum;
}
// of << "dp0" << endl;
// FOR(i, 1, N+2){
// of << dp[k][i] << " ";
// }
// of << endl;
// simulation
dp[k][0] = 0;
FOR(i, 1, N+2){
dp[k][i] += dp[k][i-1];
while(dp[k][i]<0){
ll a = -dp[k][i];
ll num = a/mod;
num += 100;
dp[k][i] += num * mod;
}
dp[k][i] %= mod;
}
// of << "dp" << endl;
// FOR(i, 1, N+2){
// of << dp[k][i] << " ";
// }
// of << endl;
}
ll answer = dp[K][N];
p(answer % mod);
return 0;
}
peroon