제출 #891283

#제출 시각아이디문제언어결과실행 시간메모리
891283iris2617Financial Report (JOI21_financial)C++14
0 / 100
4058 ms29392 KiB
#include<bits/stdc++.h> #define int long long #define matsuri pair<int,int> //const int iris = 1e9+7; const int iris = 998244353; using namespace std; const int N=3e5; struct sagiri { vector<int> st; sagiri() { st.resize(N*4, 0); } void mdf(int i,int l,int r,int p,int x) { int m=l+(r-l)/2; if(l==r) { st[i]=x; return; } if(p<=m) mdf(i*2,l,m,p,x); else mdf(i*2+1,m+1,r,p,x); st[i]=max(st[i*2], st[i*2+1]); } int qry(int i,int l,int r,int L,int R) { int m=l+(r-l)/2; if(L<=l && r<=R) return st[i]; else if(R<=m) return qry(i*2,l,m,L,R); else if(L>m) return qry(i*2+1,m+1,r,L,R); else return max(qry(i*2,l,m,L,r), qry(i*2+1,m+1,r,L,R) ); } }dis, dp; void solve() { int n,d; cin>>n>>d; vector<matsuri> arr; for(int i=1;i<=n;i++) { int a; cin>>a; arr.emplace_back(a,-i); } sort(arr.begin(), arr.end()); set<int> s; dp.mdf(1,0,n,0,0); s.insert(0); dis.mdf(1,0,n,0,n); for(auto [a,i]:arr) { i*=-1; s.insert(i); auto it=s.find(i); it--; dis.mdf(1,0,n,*it,i-*it); int l=0, r=i; //cout<<i<<' '<<a<<'\n'; while(l<r) { int m=l+(r-l)/2; //cout<<" - "<<m<<' '<<dis.qry(1,0,n,m,i)<<'\n'; //for(int j=m;j<=i;j++) // cout<<" "<<dis.qry(1,0,n,j,j)<<'\n'; if(dis.qry(1,0,n,m,i)<=d) r=m; else l=m+1; } it=upper_bound(s.begin(), s.end(), a); if(it==s.end()) dis.mdf(1,0,n,i,n-i); else dis.mdf(1,0,n,i,*it-i); //cout<<' '<<l<<' '<<i<<' '<<dp.qry(1,0,n,l,i)<<'\n'; dp.mdf(1,0,n,i,dp.qry(1,0,n,l,i)+1); } cout<<dp.qry(1,0,n,0,n)<<'\n'; } signed main() { ios::sync_with_stdio(0); cin.tie(0); int T=1; //cin>>T; while(T--) solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void solve()':
Main.cpp:63:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   63 |  for(auto [a,i]:arr)
      |           ^
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...