Submission #409566

#TimeUsernameProblemLanguageResultExecution timeMemory
409566jeqchoBoat (APIO16_boat)C++17
31 / 100
2113 ms270600 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define rsz resize #define sz(x) int(x.size()) #define all(x) begin(x), end(x) #define fi first #define se second int const N=5e2+3; int a[N],b[N]; int const D=1e6+3; ll dp[D]; ll mod =1e9+7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; set<int> st; F0R(i,n) { cin>>a[i]>>b[i]; FOR(j,a[i],b[i]+1) { st.insert(j); } } vi v(all(st)); map<int,int>mp; F0R(i,sz(st)) { mp[v[i]]=i+1; } F0R(i,n) { a[i]=mp[a[i]]; b[i]=mp[b[i]]; } F0R(j,sz(st)+1) { dp[j]=0; } dp[0]=1; F0R(i,n) { ll sum=0; F0R(j,b[i]+1) { ll temp = dp[j]; if(j>=a[i]) { dp[j]+=sum; dp[j]%=mod; } sum += temp; sum%=mod; } } ll ans=0; FOR(j,1,sz(st)+1) { ans+=dp[j]; ans%=mod; } cout<<ans<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...