Submission #923229

#TimeUsernameProblemLanguageResultExecution timeMemory
923229vjudge1Boat (APIO16_boat)C++17
31 / 100
83 ms17860 KiB
#include<bits/stdc++.h> #define X first #define Y second #define all(x) begin(x), end(x) #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define FORD(i, b, a) for(int i = (b); i >= (a); i--) #define REP(i, a, b) for (int i = (a); i < (b); i++) #define mxx max_element #define mnn min_element #define SQR(x) (1LL * (x) * (x)) #define MASK(i) (1LL << (i)) #define Point Vector #define left Left #define right Right #define div Div using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ld; typedef pair<db, db> pdb; typedef pair<ld, ld> pld; typedef pair<int, int> pii; typedef pair<int, pii> piii; typedef pair<ll, ll> pll; typedef pair<ll, pll> plll; typedef pair<ll, int> pli; typedef pair<ll, pii> plii; template<class A, class B> bool maximize(A& x, B y) { if (x < y) return x = y, true; else return false; } template<class A, class B> bool minimize(A& x, B y) { if (x > y) return x = y, true; else return false; } /* END OF TEMPLATE */ const int N = 5e2 + 7; const int mod = 1e9 + 7; int n, a[N], b[N]; void add(int& x, int y) { if ((x+=y) >= mod) x-=mod; } namespace sub12 { const int N = 1e6 + 5008; struct BIT { int bit[N], n; BIT() { n = 0; REP(i, 0, N) bit[i] = 0; } void update(int p, int u) { for (; p <= n; p+=p & -p) bit[p] = (bit[p] + u) % mod; } int Get(int p) { int res = 0; for (; p > 0; p-=p & -p) res = (res + bit[p]) % mod; return res; } } bit; int f[N], pre[N]; vector<int> E; void buildE() { FOR(i, 1, n) FOR(j, a[i], b[i]) E.push_back(j); sort(all(E)); vector<int> new_E; for (auto x : E) if (new_E.empty() || new_E.back() != x) new_E.push_back(x); E = new_E; } void Process() { buildE(); bit.n = (int)E.size(); int m = E.size(); FOR(i, 1, n) { a[i] = lower_bound(all(E), a[i]) - E.begin() + 1; b[i] = lower_bound(all(E), b[i]) - E.begin() + 1; FOR(j, a[i], b[i]) { f[j] = bit.Get(j - 1) + 1; } FOR(j, a[i], b[i]) bit.update(j, f[j]); } cout<<bit.Get(m); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; ll sum = 0; FOR(i, 1, n) { cin>>a[i]>>b[i]; sum+=b[i] - a[i]; } if (sum <= 1e6) { sub12::Process(); return 0; } 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...