This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <chrono>
#define maxn 505
#define maxlog 20
#define mod 1000000007
#define INF 1000000010
#define LINF 1000000000000000005
#define endl '\n'
#define pb(x) push_back(x)
#define X first
#define Y second
#define control cout<<"passed"<<endl;
#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")
#pragma GCC target("avx2")
using namespace std;
std::chrono::high_resolution_clock::time_point startT, currT;
constexpr double TIME_MULT = 1;
double timePassed()
{
using namespace std::chrono;
currT = high_resolution_clock::now();
double time = duration_cast<duration<double>>(currT - startT).count();
return time * TIME_MULT;
}
int l[maxn], r[maxn];
int n;
int dp[maxn];
void read()
{
cin >> n;
for(int i = 1; i <= n; i++)
cin >> l[i] >> r[i];
}
int ans = 0;
void calc_dp()
{
dp[0] = 1;
for(int i = 1; i <= n; i++)
for(int j = i - 1; j > -1; j--)
if(l[i] > l[j])
{
dp[i] += dp[j];
if(dp[i] >= mod)
dp[i] -= mod;
}
for(int i = 1; i <= n; i++)
{
ans += dp[i];
if(ans >= mod)
ans -= mod;
}
cout << ans << endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//startT = std::chrono::high_resolution_clock::now();
read();
calc_dp();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |