Submission #1015088

#TimeUsernameProblemLanguageResultExecution timeMemory
1015088vjudge1Boat (APIO16_boat)C++17
31 / 100
2047 ms454396 KiB
#include <bits/stdc++.h> using namespace std; const int M = 1e6 + 1, mod = 1e9 + 7; int fen[M+1]; void modify(int p,int x) { p++; while (p<=M) { fen[p]+=x; fen[p]%=mod; p+=p&-p; } } int get(int p) { int ans=0; p++; while (p) { ans+=fen[p]; ans%=mod; p-=p&-p; } return ans; } int main() { int n; cin>>n; int a[n],b[n]; set<int> se; for (int i=0;i<n;i++) { cin>>a[i]>>b[i]; for (int j=a[i];j<=b[i];j++) se.insert(j); } map<int,int> mp; for (int i:se) mp[i]=mp.size()+1; modify(0,1); for (int i=0;i<n;i++) { a[i]=mp[a[i]],b[i]=mp[b[i]]; for (int j=b[i];j>=a[i];j--) modify(j,get(j-1)); } cout<<get(M)-1<<endl; 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...