제출 #1120147

#제출 시각아이디문제언어결과실행 시간메모리
112014712345678Bouquet (EGOI24_bouquet)C++17
100 / 100
64 ms14696 KiB
#include <bits/stdc++.h> using namespace std; const int nx=2e5+5; int n, l, r, dp[nx], ans; vector<int> upd[nx]; struct fenwick { int d[nx]; void update(int i, int vl) {while (i<nx) d[i]=max(d[i], vl), i+=(i&-i);} int query(int i) { int res=0; while (i>0) res=max(res, d[i]), i-=(i&-i); return res; } } f; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n; for (int i=1; i<=n; i++) { cin>>l>>r; for (auto x:upd[i]) f.update(x, dp[x]); dp[i]=f.query(max(0, i-l-1))+1; upd[min(n+1, i+r+1)].push_back(i); ans=max(ans, dp[i]); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...