| 记录编号 |
610586 |
评测结果 |
AAAAA |
| 题目名称 |
1141.[湖北2011寒假] 求M数 |
最终得分 |
100 |
| 用户昵称 |
贺元莘 |
是否通过 |
通过 |
| 代码语言 |
C++ |
运行时间 |
0.635 s |
| 提交时间 |
2026-01-13 20:09:45 |
内存使用 |
5.79 MiB |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
stack<int> a;
int b[1000002], n;
int main() {
freopen("allm.in","r",stdin);
freopen("allm.out","w",stdout);
scanf("%d", &n);
for(int i = 1; i <= n; i++) {
scanf("%d", &b[i]);
while(!a.empty() && a.top() >= b[i]) {
a.pop();
}
if(a.empty()) {
printf("0 ");
} else {
printf("%d ", a.top());
}
a.push(b[i]);
}
return 0;
}