题目链接:http://www.codeforces.com/problemset/problem/155/A
题意:找到当前最大值或者最小值出现的次数。“当前”的意思差不多是a[i]大于所有a[j](j小于i)或者大于所有a[j]。
C++代码:
#include <iostream>
using namespace std;
int n, a[];
int main()
{
cin >> n;
for (int i = ; i < n; i++)
cin >> a[i];
int Low = a[], High = a[], cnt = ;
for (int i = ; i < n; i ++)
{
if (a[i] > High)
{
High = a[i];
cnt ++;
}
else if (a[i] < Low)
{
Low = a[i];
cnt ++;
}
}
cout << cnt;
return ;
}
C++