$60pts$,前6个点AC,后4个点 $1.18$ ~ $1.50$ 之间的吧
by Kasa_ @ 2023-05-13 23:19:45
3e6 的 IO 量为啥用 cin/cout 硬冲啊。/fad
by XeCtera @ 2023-05-13 23:19:57
3e6 的数据还用 cin/cout 显示出了什么。
by Etinorally @ 2023-05-13 23:21:39
你好歹关一下同步流
by Etinorally @ 2023-05-13 23:22:59
@[Kasa_](/user/941962) 还有 $10^5$ 的数据某些暴力老哥+卡常大神的 $O(n^2)$ 也是能冲过去的(
by RNTBW @ 2023-05-14 00:01:05
@[Kasa_](/user/941962) 这道题用个scanf和printf或者用快速读入都能过
```cpp
#include<iostream>
#include<stack>
using namespace std;
stack<int> s;
int n,a[3000001],ans[3000001];
inline int read()
{
int x=0,f=1;
char ch=getchar();
while(!isdigit(ch))
{
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch))
{
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++) a[i]=read();
for(int i=n;i>=1;i--)
{
while(!s.empty()&&a[i]>=a[s.top()]) s.pop();
if(s.empty()) ans[i]=0;
else ans[i]=s.top();
s.push(i);
}
for(int i=1;i<=n;i++) cout<<ans[i]<<' ';
return 0;
}
```
我用的快速读入,希望有帮助
by Li_wc @ 2023-08-16 14:53:09
@[Li_wc](/user/1048171) thx
by Kasa_ @ 2023-08-16 16:43:55