Submission #30778

#TimeUsernameProblemLanguageResultExecution timeMemory
30778kavunBoat (APIO16_boat)C++14
0 / 100
0 ms1844 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; const int maxn = 501; int dp[maxn][1000001], a[1000001], b[1000001], ans; int n; int f(int i, int j) { if(j > b[i] - a[i]) return 0; if(dp[i][j]) return dp[i][j]; if(i == 0 && j <= b[i] - a[i]) return 1; for(int k = 0; k < i; k++) for(int l = 0;l < a[i]+j-a[k]; l++) dp[i][j] += f(k,l); return ++dp[i][j]; } int main() { cin >> n; for(int i = 0; i < n; i++) cin >> a[i] >> b[i]; for(int i = 0; i < n; i++) for(int j = 0; j <= b[i] - a[i]; j++) ans = (ans + f(i,j)) % mod; cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...