#include <bits/stdc++.h>
using namespace std;
#define MAX 510
#define all(v) v.begin(), v.end()
#define ln '\n'
#define MOD 1000000007
#define INF 210000000000
#define pb push_back
#define abs(x) (((x)>0)?(x):(-(x)))
#define len(x) ((x).second-(x).first)
typedef long long ll;
vector<int> dp[MAX], sum[MAX];
int A[MAX], B[MAX];
int main(void) {
ios::sync_with_stdio(false);
cin.tie(0);
int N;
cin >> N;
int i, j, k;
for (i = 1; i <= N; i++) cin >> A[i] >> B[i], dp[i].pb(0), sum[i].pb(0);
for (i = A[1]; i <= B[1]; i++) {
dp[1].pb(1);
sum[1].pb(0);
sum[1][i - A[1] + 1] = (sum[1][i - A[1]] + dp[1][i - A[1] + 1]) % MOD;
}
for (i = 2; i <= N; i++) {
for (j = A[i]; j <= B[i]; j++) dp[i].pb(1), sum[i].pb(0);
for (j = A[i]; j <= B[i]; j++) {
for (k = 1; k <= N - 1; k++) {
if (j - A[k] <= 0) continue;
dp[i][j - A[i] + 1] += sum[k][min(j - A[k], (int)(sum[k].size() - 1))];
dp[i][j - A[i] + 1] %= MOD;
}
}
for (j = A[i]; j <= B[i]; j++) sum[i][j - A[i] + 1] = (sum[i][j - A[i]] + dp[i][j - A[i] + 1]) % MOD;
}
int ans = 0;
for (i = 1; i <= N; i++) ans += sum[i][sum[i].size() - 1];
ans %= MOD;
while (ans < 0) ans += MOD;
cout << ans << ln;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1357 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |