Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string>
- using namespace std;
- typedef long long ll;
- const int maxn = 1e5 + 10;
- const ll MOD = 1e9 + 7;
- ll P, B;
- int n;
- ll arr[maxn];
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin >> P >> B;
- cin >> n;
- for(int i = 1; i <= n; i++) {
- cin >> arr[i];
- }
- ll dp[n + 2][n + 2][n + 2] ;
- memset(dp, 0, sizeof dp);
- dp[1][0][0] = 1;
- for(int a = 0; a <= n; a++) {
- for(int b = 0; b <= n; b++) {
- for(int i = 1; i <= n; i++) {
- // binary_search
- int next = (i + 1);
- int current = (i);
- if(a == 0 or arr[i] - arr[a] >= P) {
- // query(i, b) += dp[current][a][b];
- dp[next][i][b] += dp[current][a][b];
- if(dp[next][i][b] >= MOD) {
- dp[next][i][b] -= MOD;
- }
- }
- if(b == 0 or arr[i] - arr[b] >= B) {
- dp[next][a][i] += dp[current][a][b];
- if(dp[next][a][i] >= MOD) {
- dp[next][a][i] -= MOD;
- }
- }
- }
- }
- }
- ll ret = 0;
- // cout << dp[0][n][n] << " "<< dp[1][n][n]
- for(int a = 0; a <= n; a++) {
- for(int b = 0; b <= n; b++) {
- ret += dp[n + 1][a][b];
- ret %= MOD;
- cout << dp[0][a][b] << " " << dp[1][a][b] << endl;
- }
- }
- cout << ret << endl;
- return 0;
- }
- /*
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement