Submission #960107

# Submission time Handle Problem Language Result Execution time Memory
960107 2024-04-09T16:33:33 Z kim Boat (APIO16_boat) C++17
0 / 100
2 ms 4312 KB
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define eb emplace_back

const ll md=1e9+7;

vector<int> comp;
int a[505],b[505];
ll dp[505][1005];

int main(){
    ios::sync_with_stdio(false); cin.tie(0);

    int n; cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i]>>b[i];
        comp.eb(--a[i]), comp.eb(b[i]);
    }
    comp.eb(0);
    sort(comp.begin(),comp.end());
    comp.erase(unique(comp.begin(),comp.end()),comp.end());
    int m=comp.size();
    for(int i=0;i<m;++i) dp[0][i]=1;
    for(int i=1;i<=n;++i){
        a[i]=lower_bound(comp.begin(),comp.end(),a[i])-comp.begin();
        b[i]=lower_bound(comp.begin(),comp.end(),b[i])-comp.begin();
        dp[i][0]=dp[i-1][m-1];
        for(int j=1;j<m;++j){
            if(a[i]<j&&j<=b[i]) dp[i][j]=((dp[i][j-1]+dp[i-1][j-1]*(comp[j]-comp[j-1]))%md+md)%md;
            else dp[i][j]=dp[i][j-1];
        }
    }
    cout<<(dp[n][m-1]-1+md)%md;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4312 KB Output isn't correct
2 Halted 0 ms 0 KB -