Submission #917981

#TimeUsernameProblemLanguageResultExecution timeMemory
917981irmuunBoat (APIO16_boat)C++17
9 / 100
664 ms524288 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() const ll mod=1e9+7; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n; cin>>n; ll a[n+5],b[n+5]; ll ans=0; vector<ll>dp[n+5]; for(ll i=1;i<=n;i++){ cin>>a[i]>>b[i]; dp[i].resize(b[i]-a[i]+1); } dp[0].pb(1);//first is 0,then ai, ... ,bi for(ll i=1;i<=n;i++){ ll tot=1; dp[i][0]=1; ll c[n+5]; for(ll j=1;j<=n;j++){ c[j]=a[j]; } for(ll j=a[i];j<=b[i];j++){ for(ll k=1;k<i;k++){ while(c[k]<j&&c[k]<=b[k]){ tot+=dp[k][c[k]-a[k]+1]; tot%=mod; c[k]++; } } dp[i][j-a[i]+1]=tot; ans+=dp[i][j-a[i]+1]; ans%=mod; } } cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...