Submission #672247

#TimeUsernameProblemLanguageResultExecution timeMemory
672247Dan4LifeBoat (APIO16_boat)C++17
9 / 100
2077 ms524288 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second const int maxn = 5e2+10; const int MOD = (int)1e9+7; pair<int,int> a[maxn]; unordered_map<int,int> dp[maxn]; int n; int32_t main() { cin >> n; int ans = 0; for(int i = 0; i < n; i++) cin >> a[i].fi >> a[i].se; for(int i = 0; i < n; i++){ for(int j = a[i].fi; j <= a[i].se; j++){ dp[i][j]=1; if(j>a[i].fi) dp[i][j]+=dp[i][j-1]; if(dp[i][j]>MOD) dp[i][j]-=MOD; for(int k = 0; k < i; k++){ if(j>a[k].fi) dp[i][j]+=dp[k][min(j-1,a[k].se)]; if(dp[i][j]>MOD) dp[i][j]-=MOD; } } } for(int i = 0; i < n; i++) ans+=dp[i][a[i].se], ans-=(ans>MOD?MOD:0); cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...