#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
#define pb push_back
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define fi first
#define se second
int const N=5e2+3;
int const A=1e3+3;
int a[N],b[N];
ll dp[N][2*N];
ll mod =1e9+7;
bitset<2*N> vis[N];
int n;
ll recur(int now, int mx)
{
if(now==n)
{
if(mx!=0)return 1;
return 0;
}
if(vis[now][mx])return dp[now][mx];
vis[now][mx]=1;
ll ans=recur(now+1,mx);
if(mx<a[now])
{
ans+=recur(now+1,a[now]);
ans%=mod;
}
dp[now][mx]=ans;
return ans;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n;
set<int> st;
F0R(i,n)
{
cin>>a[i]>>b[i];
st.insert(a[i]);
st.insert(b[i]);
}
map<int,int>mp;
int idx=1;
trav(e,st)
{
mp[e]=idx;
++idx;
}
F0R(i,n)
{
a[i]=mp[a[i]];
b[i]=mp[b[i]];
}
cout<<recur(0,0)<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
4256 KB |
Output is correct |
2 |
Correct |
5 ms |
4304 KB |
Output is correct |
3 |
Correct |
5 ms |
4300 KB |
Output is correct |
4 |
Correct |
5 ms |
4300 KB |
Output is correct |
5 |
Correct |
5 ms |
4300 KB |
Output is correct |
6 |
Correct |
4 ms |
3788 KB |
Output is correct |
7 |
Correct |
4 ms |
3788 KB |
Output is correct |
8 |
Correct |
4 ms |
4044 KB |
Output is correct |
9 |
Correct |
5 ms |
3916 KB |
Output is correct |
10 |
Correct |
4 ms |
4044 KB |
Output is correct |
11 |
Correct |
5 ms |
3916 KB |
Output is correct |
12 |
Correct |
5 ms |
4300 KB |
Output is correct |
13 |
Correct |
5 ms |
4044 KB |
Output is correct |
14 |
Correct |
6 ms |
3820 KB |
Output is correct |
15 |
Correct |
5 ms |
4172 KB |
Output is correct |
16 |
Correct |
2 ms |
2688 KB |
Output is correct |
17 |
Correct |
2 ms |
2764 KB |
Output is correct |
18 |
Correct |
3 ms |
2764 KB |
Output is correct |
19 |
Correct |
2 ms |
2760 KB |
Output is correct |
20 |
Correct |
3 ms |
2764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
4256 KB |
Output is correct |
2 |
Correct |
5 ms |
4304 KB |
Output is correct |
3 |
Correct |
5 ms |
4300 KB |
Output is correct |
4 |
Correct |
5 ms |
4300 KB |
Output is correct |
5 |
Correct |
5 ms |
4300 KB |
Output is correct |
6 |
Correct |
4 ms |
3788 KB |
Output is correct |
7 |
Correct |
4 ms |
3788 KB |
Output is correct |
8 |
Correct |
4 ms |
4044 KB |
Output is correct |
9 |
Correct |
5 ms |
3916 KB |
Output is correct |
10 |
Correct |
4 ms |
4044 KB |
Output is correct |
11 |
Correct |
5 ms |
3916 KB |
Output is correct |
12 |
Correct |
5 ms |
4300 KB |
Output is correct |
13 |
Correct |
5 ms |
4044 KB |
Output is correct |
14 |
Correct |
6 ms |
3820 KB |
Output is correct |
15 |
Correct |
5 ms |
4172 KB |
Output is correct |
16 |
Correct |
2 ms |
2688 KB |
Output is correct |
17 |
Correct |
2 ms |
2764 KB |
Output is correct |
18 |
Correct |
3 ms |
2764 KB |
Output is correct |
19 |
Correct |
2 ms |
2760 KB |
Output is correct |
20 |
Correct |
3 ms |
2764 KB |
Output is correct |
21 |
Incorrect |
6 ms |
4300 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
4256 KB |
Output is correct |
2 |
Correct |
5 ms |
4304 KB |
Output is correct |
3 |
Correct |
5 ms |
4300 KB |
Output is correct |
4 |
Correct |
5 ms |
4300 KB |
Output is correct |
5 |
Correct |
5 ms |
4300 KB |
Output is correct |
6 |
Correct |
4 ms |
3788 KB |
Output is correct |
7 |
Correct |
4 ms |
3788 KB |
Output is correct |
8 |
Correct |
4 ms |
4044 KB |
Output is correct |
9 |
Correct |
5 ms |
3916 KB |
Output is correct |
10 |
Correct |
4 ms |
4044 KB |
Output is correct |
11 |
Correct |
5 ms |
3916 KB |
Output is correct |
12 |
Correct |
5 ms |
4300 KB |
Output is correct |
13 |
Correct |
5 ms |
4044 KB |
Output is correct |
14 |
Correct |
6 ms |
3820 KB |
Output is correct |
15 |
Correct |
5 ms |
4172 KB |
Output is correct |
16 |
Correct |
2 ms |
2688 KB |
Output is correct |
17 |
Correct |
2 ms |
2764 KB |
Output is correct |
18 |
Correct |
3 ms |
2764 KB |
Output is correct |
19 |
Correct |
2 ms |
2760 KB |
Output is correct |
20 |
Correct |
3 ms |
2764 KB |
Output is correct |
21 |
Incorrect |
6 ms |
4300 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |