Submission #30778

# Submission time Handle Problem Language Result Execution time Memory
30778 2017-07-26T13:01:45 Z kavun Boat (APIO16_boat) C++14
0 / 100
0 ms 1844 KB
#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 time Memory Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -