I_love_%username%

简介: I_love_%username%

文章目录

一、I_love_%username%

总结


一、I_love_%username%

本题链接:


题目:

A. I_love_%username%

time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

Vasya adores sport programming. He can’t write programs but he loves to watch the contests’ progress. Vasya even has a favorite coder and Vasya pays special attention to him.


One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).


Vasya considers a coder’s performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder’s first contest isn’t considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can’t code… That’s why he asks you to help him.


Input

The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.


The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.


Output

Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.


Examples

input

5

100 50 200 150 200

output

2

input

10

4664 6496 5814 7010 5762 5736 6944 4850 3698 7242

output

4

Note

In the first sample the performances number 2 and 3 are amazing.


In the second sample the performances number 2, 4, 9 and 10 are amazing.


本博客给出本题截图:

image.png

题意:输入一串数字,输入的过程中,如果当前输入的这个数比之前的数都要大或小,那么就让res ++最后输出res的值

AC代码

#include <iostream>
using namespace std;
const int N = 1010;
int a[N];
int res;
int main()
{
    int n;
    cin >> n;
    int max, min;
    for (int i = 0; i < n; i ++ ) 
    {
        cin >> a[i];
        if (i == 0)
        {
            max = a[i];
            min = a[i];
        }
        if (a[i] > max)
        {
            max = a[i];
            res ++;
        }
        if (a[i] < min)
        {
            min = a[i];
            res ++;
        }
    }
    cout << res << endl;
    return 0;
}

总结

水题,不解释


目录
相关文章
|
12月前
|
Python
Python:字符串基操_strip()/rstrip()/lstrip()_lower()/upper()_startswith()/endswith()_split()/rspilt()_join
Python:字符串基操_strip()/rstrip()/lstrip()_lower()/upper()_startswith()/endswith()_split()/rspilt()_join
96 0
Python3中strip()、lstrip()、rstrip()用法详解
Python3中strip()、lstrip()、rstrip()用法详解
|
前端开发 JavaScript
一百种语言的LOVE
一百种语言的LOVE
51 0
一百种语言的LOVE
L1-026 I Love GPLT (5 分)
L1-026 I Love GPLT (5 分)
109 0
|
Python
ZZULIOJ-1028,I love 闰年!(Python)
ZZULIOJ-1028,I love 闰年!(Python)
|
存储
HDOJ/HDU 2140 Michael Scofield's letter(字符转换~)
HDOJ/HDU 2140 Michael Scofield's letter(字符转换~)
72 0
转:肉饼的自白:You&#39;ve got to find what you love
《You've got to find what you love》是乔布斯2005年在斯坦福大学毕业典礼上的演讲,当我第一次看到这个演讲视频的时候,被彻底震住了。回顾自己跌跌撞撞的人生道路,就是一个不断寻找然后坚持自己钟爱事业的过程。
1357 0