题解(C++)

CC  •  2年前


#include<bits/stdc++.h>
using namespace std;

int a[1010];
int main() 
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int ret = 0;
	for (int i = 0; i < n; i++)
	{
		int front = 0;
		for (int j = 0; j < i; j++)
		{
			front += (a[j] > a[i]);
		}
		int back = 0;
		for (int j = n-1; j > i; j--)
		{
			back += (a[j] > a[i]);
		}
		ret += (front == back);
	}
	cout << ret;
	return 0;
}

评论:

请先登录,才能进行评论