icpc:problems:luogup1165
problems | |
---|---|
名称 | 日志分析 |
题目编号 | P1165 |
题目链接 | luogu.com.cn/… |
来源 | Luogu |
算法分类 | 栈, 栈_例题 |
难易程度 | 容易 |
日志分析
想法
维护最大值栈,入栈时比较,最大值才有价值。
代码实现
#include<cstdio> #include<algorithm> using namespace std; const int N = 1e5*2+10; int sta[N], top; int main() { int T, mod, temp; scanf("%d", &T); while(T--) { scanf("%d", &mod); if(mod == 0) { scanf("%d", &temp); sta[top+1] = max(sta[top], temp); top++; } else if(mod == 1) { top--; } else if(mod == 2) { printf("%d\n", sta[top]); } } return 0; }
/app/www/public/data/pages/icpc/problems/luogup1165.txt · 最后更改: 2024/01/30 11:50 由 温婕莺