#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,a[550],b[550],j,k,has,mo=1000000007;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(i=1;i<=n;i++)
{
cin>>a[i]>>b[i];
}
vector<ll> v[550],p[550];
for(i=n;i>=1;i--)
{
for(j=a[i];j<=b[i];j++)
{
ll tem=1;
for(k=i+1;k<=n;k++)
{
if(j>=b[k])
continue;
tem+=p[k][max(0LL,j-a[k]+1)];
tem%=mo;
}
v[i].pb(tem);
p[i].pb(0);
has+=tem;
has%=mo;
}
p[i].pb(0);
for(j=b[i]-a[i];j>=0;j--)
p[i][j]=(p[i][j+1]+v[i][j])%mo;
}
cout<<has<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
500 KB |
Output is correct |
3 |
Correct |
4 ms |
692 KB |
Output is correct |
4 |
Correct |
3 ms |
692 KB |
Output is correct |
5 |
Correct |
4 ms |
692 KB |
Output is correct |
6 |
Correct |
4 ms |
692 KB |
Output is correct |
7 |
Correct |
5 ms |
692 KB |
Output is correct |
8 |
Correct |
4 ms |
692 KB |
Output is correct |
9 |
Correct |
5 ms |
692 KB |
Output is correct |
10 |
Correct |
4 ms |
800 KB |
Output is correct |
11 |
Correct |
4 ms |
916 KB |
Output is correct |
12 |
Correct |
4 ms |
916 KB |
Output is correct |
13 |
Correct |
4 ms |
916 KB |
Output is correct |
14 |
Correct |
4 ms |
916 KB |
Output is correct |
15 |
Correct |
5 ms |
916 KB |
Output is correct |
16 |
Correct |
3 ms |
992 KB |
Output is correct |
17 |
Correct |
3 ms |
992 KB |
Output is correct |
18 |
Correct |
4 ms |
992 KB |
Output is correct |
19 |
Correct |
4 ms |
992 KB |
Output is correct |
20 |
Correct |
4 ms |
992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
500 KB |
Output is correct |
3 |
Correct |
4 ms |
692 KB |
Output is correct |
4 |
Correct |
3 ms |
692 KB |
Output is correct |
5 |
Correct |
4 ms |
692 KB |
Output is correct |
6 |
Correct |
4 ms |
692 KB |
Output is correct |
7 |
Correct |
5 ms |
692 KB |
Output is correct |
8 |
Correct |
4 ms |
692 KB |
Output is correct |
9 |
Correct |
5 ms |
692 KB |
Output is correct |
10 |
Correct |
4 ms |
800 KB |
Output is correct |
11 |
Correct |
4 ms |
916 KB |
Output is correct |
12 |
Correct |
4 ms |
916 KB |
Output is correct |
13 |
Correct |
4 ms |
916 KB |
Output is correct |
14 |
Correct |
4 ms |
916 KB |
Output is correct |
15 |
Correct |
5 ms |
916 KB |
Output is correct |
16 |
Correct |
3 ms |
992 KB |
Output is correct |
17 |
Correct |
3 ms |
992 KB |
Output is correct |
18 |
Correct |
4 ms |
992 KB |
Output is correct |
19 |
Correct |
4 ms |
992 KB |
Output is correct |
20 |
Correct |
4 ms |
992 KB |
Output is correct |
21 |
Execution timed out |
2059 ms |
13632 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1041 ms |
524288 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
500 KB |
Output is correct |
3 |
Correct |
4 ms |
692 KB |
Output is correct |
4 |
Correct |
3 ms |
692 KB |
Output is correct |
5 |
Correct |
4 ms |
692 KB |
Output is correct |
6 |
Correct |
4 ms |
692 KB |
Output is correct |
7 |
Correct |
5 ms |
692 KB |
Output is correct |
8 |
Correct |
4 ms |
692 KB |
Output is correct |
9 |
Correct |
5 ms |
692 KB |
Output is correct |
10 |
Correct |
4 ms |
800 KB |
Output is correct |
11 |
Correct |
4 ms |
916 KB |
Output is correct |
12 |
Correct |
4 ms |
916 KB |
Output is correct |
13 |
Correct |
4 ms |
916 KB |
Output is correct |
14 |
Correct |
4 ms |
916 KB |
Output is correct |
15 |
Correct |
5 ms |
916 KB |
Output is correct |
16 |
Correct |
3 ms |
992 KB |
Output is correct |
17 |
Correct |
3 ms |
992 KB |
Output is correct |
18 |
Correct |
4 ms |
992 KB |
Output is correct |
19 |
Correct |
4 ms |
992 KB |
Output is correct |
20 |
Correct |
4 ms |
992 KB |
Output is correct |
21 |
Execution timed out |
2059 ms |
13632 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |