为什么1-6WA,7-10RE
查看原帖
为什么1-6WA,7-10RE
1502450
Iwishhunnen楼主2024/10/16 14:55
#include<iostream>
#include<stack>
using namespace std;
int main()
{
	long int n;
	int mount[10000], f[10000] = {0};
	cin >> n;
	stack<int>s;
	for (int i = 0; i < n; i++)
		cin >> mount[i];
	for (int i = 0; i < n; i++)
	{
		if (s.size())
		{
			int si;
			si = s.size();
			for (int j = 0; j < si; j++)
			{
				if (mount[i] <= mount[s.top()])break;
				if (mount[i] > mount[s.top()])
				{
					f[s.top()] = i + 1;
					s.pop();
				}
			}
			s.push(i);
		}
		else s.push(i);
	}
	for (int i = 0; i < n; i++)
		cout << f[i];
	return 0;
}
2024/10/16 14:55
加载中...