Submission #1015086

# Submission time Handle Problem Language Result Execution time Memory
1015086 2024-07-06T04:58:56 Z vjudge1 Boat (APIO16_boat) C++17
31 / 100
1110 ms 524288 KB
#include<bits/stdc++.h>

using namespace std;

const int mod = 1'000'000'007;

int main()
{
  int n;
  cin >> n;
  int a[1 + n], b[1 + n]; // [a[i], a[i] + b[i])
  a[0] = 0, b[0] = 1;
  for(int i = 1; i <= n; i++)
    {
      cin >> a[i] >> b[i];
      b[i] = b[i] - a[i] + 1;
    }

  

  vector<vector<int> > dp(1 + n);
  dp[0].push_back(1);

  for(int i = 1; i <= n; i++)
    {
      dp[i].resize(b[i]);
      for(int j = 0; j < b[i]; j++)
	{
	  int x = a[i] + j;
	  for(int k = 0; k < i; k++)
	    {
	      int len = min(b[k], max(0, x - a[k]));
	      if(len > 0) dp[i][j] += dp[k][len - 1];
	      dp[i][j] %= mod;
	    }
	}

      for(int j = 1; j < b[i]; j++)
	dp[i][j] += dp[i][j - 1], dp[i][j] %= mod;
    }
  int ans = 0;
  for(int i = 1; i <= n; i ++)
    ans += dp[i].back(), ans %= mod;
  cout << ans << endl;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 464 KB Output is correct
17 Correct 1 ms 444 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 464 KB Output is correct
17 Correct 1 ms 444 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 677 ms 3648 KB Output is correct
22 Correct 685 ms 3684 KB Output is correct
23 Correct 697 ms 3552 KB Output is correct
24 Correct 690 ms 3804 KB Output is correct
25 Correct 679 ms 3920 KB Output is correct
26 Correct 781 ms 4176 KB Output is correct
27 Correct 846 ms 4204 KB Output is correct
28 Correct 838 ms 4176 KB Output is correct
29 Correct 823 ms 4040 KB Output is correct
30 Correct 1110 ms 4092 KB Output is correct
31 Correct 1069 ms 4344 KB Output is correct
32 Correct 1071 ms 4180 KB Output is correct
33 Correct 1064 ms 4180 KB Output is correct
34 Correct 1054 ms 4180 KB Output is correct
35 Correct 696 ms 3896 KB Output is correct
36 Correct 797 ms 4152 KB Output is correct
37 Correct 799 ms 4236 KB Output is correct
38 Correct 842 ms 4080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 234 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 464 KB Output is correct
17 Correct 1 ms 444 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 677 ms 3648 KB Output is correct
22 Correct 685 ms 3684 KB Output is correct
23 Correct 697 ms 3552 KB Output is correct
24 Correct 690 ms 3804 KB Output is correct
25 Correct 679 ms 3920 KB Output is correct
26 Correct 781 ms 4176 KB Output is correct
27 Correct 846 ms 4204 KB Output is correct
28 Correct 838 ms 4176 KB Output is correct
29 Correct 823 ms 4040 KB Output is correct
30 Correct 1110 ms 4092 KB Output is correct
31 Correct 1069 ms 4344 KB Output is correct
32 Correct 1071 ms 4180 KB Output is correct
33 Correct 1064 ms 4180 KB Output is correct
34 Correct 1054 ms 4180 KB Output is correct
35 Correct 696 ms 3896 KB Output is correct
36 Correct 797 ms 4152 KB Output is correct
37 Correct 799 ms 4236 KB Output is correct
38 Correct 842 ms 4080 KB Output is correct
39 Runtime error 234 ms 524288 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -