Submission #487419

#TimeUsernameProblemLanguageResultExecution timeMemory
487419leakedBoat (APIO16_boat)C++14
0 / 100
23 ms1232 KiB
#include <bits/stdc++.h> #define f first #define s second #define m_p make_pair #define pb push_back #define vec vector #define sz(x) (int)(x).size() #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define pw(x) (1LL<<(x)) #define fast_iati ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);} template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);} typedef long long ll; typedef pair<int,int> pii; const int M=1e9+7; void add(int &a,int b){ a+=b; if(a>=M) a-=M; else if(a<0) a+=M; } signed main(){ fast_iati; int n; cin>>n; vec<int>a(n),b(n); vec<int> kek; for(int i=0;i<n;i++) cin>>a[i]>>b[i],kek.pb(a[i]),kek.pb(b[i]); kek.pb(0); sort(all(kek));kek.erase(unique(all(kek)),kek.end()); // dp[0][0]=1; vec<vec<int>>dp(n+1,vec<int>(sz(kek)+1,0)); // dp[0][0]=1; for(int i=0;i<n;i++){ a[i]=lower_bound(all(kek),a[i])-kek.begin(); b[i]=lower_bound(all(kek),b[i])-kek.begin(); add(dp[i][0],1); for(int j=0;j<sz(kek);j++){ for(int k=j+1;k<=b[i];k++){ add(dp[i+1][k],dp[i][j]); } } } int ans=0; for(int j=0;j<=sz(kek);j++) add(ans,dp[n][j]); add(ans,1); cout<<ans; 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...