赞
踩
题意思路如标题
- int main()
- {
- int n;
- cin >> n;
- int a[MAXN];
- for (int i = 0; i < n; ++i) {
- cin >> a[i];
- }
- int dp[MAXN];
- int mie[MAXN];
- memset(dp, 0, sizeof(dp));
- int cnt = n;
- mie[cnt] = INT_MAX;
- for (int i = n - 1; i >= 0; --i) {
- if (cnt <= n && a[i] >= mie[cnt]) cnt++;
- dp[i] = mie[cnt];
- mie[--cnt] = a[i];
- }
- for (int i = 0; i < n; ++i)
- cout << dp[i] << " ";
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。