Submission #672245

#TimeUsernameProblemLanguageResultExecution timeMemory
672245Dan4LifeBoat (APIO16_boat)C++17
0 / 100
995 ms524288 KiB
#include <bits/stdc++.h> using namespace std; #define int 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]; 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[i].se)], dp[i][j]%=MOD; } } for(int i = 0; i < n; i++) ans+=dp[i][a[i].se], ans%=MOD; 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...