正文
增加 1 行删除 24 行
124 行未改动全部展开12512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016186 行未改动124 行未改动全部展开---当然不是!我们怎么知道 Future 手中剩下的牌的最大点数?接下来,我要教大家一个很实用的函数。学会后就可以秒解一道青题:\[水题,if you learn multiset](https://www.luogu.com.cn/problem/P6412) \代码我一起放了,其实就是第一个大于,和第一个等于。```cppmultiset<int>st;//和set类似不过,set不能放入重复元素,它可以。``````cpp#include<bits/stdc++.h>#define int long longusing namespace std;multiset<int>m;int n,x,f[300005],ans;signed main(){cin>>n;f[0]=f[n+1]=-1;m.insert(0),m.insert(n+1);for(int i=1;i<=n;i++){cin>>x;auto t=m.upper_bound(x);f[x]=max(f[*t],f[*(t--)])+1;ans+=f[x];m.insert(x);cout<<ans<<"\n";}return 0;}```题目到这就完了,我给大家奉上完整代码,时间复杂度很快。:::success[AC 代码]{open}```cpp86 行未改动124 行未改动全部展开12512612712812913013113213313413513613713886 行未改动124 行未改动全部展开---当然不是!我们怎么知道 Future 手中剩下的牌的最大点数?接下来,我要教大家一个很实用的函数。学会后就可以秒解一道青题:\[水题,if you learn multiset](https://www.luogu.com.cn/problem/P6412)```cppmultiset<int>st;//和set类似不过,set不能放入重复元素,它可以。```题目到这就完了,我给大家奉上完整代码,时间复杂度很快。:::success[AC 代码]{open}```cpp86 行未改动