60分RE求助

P5788 【模板】单调栈

@[nakanomikuaini](/user/947892)
by ztyo_zysclown @ 2023-11-22 18:35:09


数组不够 @[ztyo_zysclown](/user/947854)
by ZachekFalse @ 2023-11-22 18:36:53


```cpp #include<bits/stdc++.h> using namespace std; #define int long long int venti[7110000]; int op[7110000]; stack<int> a; int n; signed main(){ cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<=n;i++){ cin>>op[i]; } for(int i=n;i>=1;i--){ while(!a.empty()&&op[a.top()]<=op[i]){ a.pop(); } if(a.empty()){ venti[i]=0; } else{ venti[i]=a.top(); } a.push(i); } for(int i=1;i<=n;i++){ cout<<venti[i]<<" "; } return 0; } ```
by ZachekFalse @ 2023-11-22 18:37:51


@[ZachekFalse](/user/1018068) 谢谢,过了
by ztyo_zysclown @ 2023-11-22 18:38:54


|