Submission #735351

# Submission time Handle Problem Language Result Execution time Memory
735351 2023-05-04T03:19:10 Z bin9638 Boat (APIO16_boat) C++17
31 / 100
1299 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;

#define N 510
#define ll long long
#define fs first
#define sc second
#define ii pair<ll,int>
#define pb push_back
#define int ll

const ll mod=1e9+7;

void selfadd(int&u,int v)
{
    u+=v;
    if(u>=mod)u-=mod;
   // u=(u+v)%mod;
}

int n,l[N],r[N];
vector<int>dp[N];

int32_t main()
{
    #ifdef SKY
    freopen("A.inp","r",stdin);
    freopen("A.out","w",stdout);
    #endif // SKY
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>l[i]>>r[i];
        dp[i].resize(r[i]-l[i]+1,0);
    }
    for(int i=1;i<=n;i++)
        for(int j=l[i];j<=r[i];j++)
        {
            dp[i][j-l[i]]=1;
            if(j>l[i])
                dp[i][j-l[i]]=dp[i][j-l[i]-1]+1;
       //     cout<<i<<" "<<j<<" "<<dp[i][j-l[i]]<<endl;
            for(int k=1;k<i;k++)
            {
                if(j>r[k])
                {
                    selfadd(dp[i][j-l[i]],dp[k].back());
                    continue;
                }
                if(j<=l[k])
                    continue;
                selfadd(dp[i][j-l[i]],dp[k][j-l[k]-1]);
            }
           // cout<<i<<" "<<j<<" "<<dp[i][j-l[i]]<<endl;
        }
    int res=0;
    for(int i=1;i<=n;i++)
        selfadd(res,dp[i].back());
    cout<<(res+mod*mod)%mod;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 761 ms 7176 KB Output is correct
22 Correct 660 ms 7132 KB Output is correct
23 Correct 674 ms 6860 KB Output is correct
24 Correct 797 ms 7380 KB Output is correct
25 Correct 767 ms 7476 KB Output is correct
26 Correct 1000 ms 7832 KB Output is correct
27 Correct 1063 ms 7972 KB Output is correct
28 Correct 1075 ms 7892 KB Output is correct
29 Correct 1099 ms 8028 KB Output is correct
30 Correct 1298 ms 8108 KB Output is correct
31 Correct 1270 ms 7892 KB Output is correct
32 Correct 1299 ms 8112 KB Output is correct
33 Correct 1237 ms 7916 KB Output is correct
34 Correct 1288 ms 7988 KB Output is correct
35 Correct 614 ms 7636 KB Output is correct
36 Correct 720 ms 7868 KB Output is correct
37 Correct 731 ms 7940 KB Output is correct
38 Correct 751 ms 7704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 205 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 761 ms 7176 KB Output is correct
22 Correct 660 ms 7132 KB Output is correct
23 Correct 674 ms 6860 KB Output is correct
24 Correct 797 ms 7380 KB Output is correct
25 Correct 767 ms 7476 KB Output is correct
26 Correct 1000 ms 7832 KB Output is correct
27 Correct 1063 ms 7972 KB Output is correct
28 Correct 1075 ms 7892 KB Output is correct
29 Correct 1099 ms 8028 KB Output is correct
30 Correct 1298 ms 8108 KB Output is correct
31 Correct 1270 ms 7892 KB Output is correct
32 Correct 1299 ms 8112 KB Output is correct
33 Correct 1237 ms 7916 KB Output is correct
34 Correct 1288 ms 7988 KB Output is correct
35 Correct 614 ms 7636 KB Output is correct
36 Correct 720 ms 7868 KB Output is correct
37 Correct 731 ms 7940 KB Output is correct
38 Correct 751 ms 7704 KB Output is correct
39 Runtime error 205 ms 524288 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -