1 条题解
-
0
#include<bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int a[N], ans[N]; stack<int> stk; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = n; i >= 1; i--) { ans[i] = stk.size(); while (stk.size() and stk.top() < a[i]) stk.pop(); stk.push(a[i]); } for (int i = 1; i <= n; i++) cout << ans[i] << ' '; return 0; }
- 1
信息
- ID
- 7946
- 时间
- 2000ms
- 内存
- 1024MiB
- 难度
- 9
- 标签
- 递交数
- 9
- 已通过
- 6
- 上传者