1 条题解
-
0梁文瀚LWH (winham) LV 9 @ 2023-5-16 21:24:29
#include <cstdio> #include <string> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int n,h[500010],stk[500010],top; long long ans; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &h[i]); for (int i = 1; i <= n; i++) { while (top != 0 && stk[top] <= h[i]) top--; ans += top; stk[++top] = h[i]; } printf("%lld", ans); return 0; }
- 1
信息
- ID
- 2501
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 10
- 标签
- 递交数
- 5
- 已通过
- 2
- 上传者