A. i_love_%username%time limit per test2 secondsmemory limit per test256 megabytesinputstandard Inputoutputstandard Output
Vasya adores sport programming. He can ' t write programs but he loves to watch the contests ' progress. Vasya even have a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where he favorite coder participated and track the progress of his coolness. For each contest where the coder participated, he wrote out a single non-negative number-the number of points his favor Ite Coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no, contests ran Simulta neously).
Vasya considers a coder ' s performance in a contest amazing in both situations:he can break either he or his wors T performance record. First, it's amazing if during the contest the coder earns strictly morepoints that he earned on each past contest. Second, it's 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 its whole history of participating in Co Ntests. But the list of earned points turned out long and Vasya can ' t code ... That's why he asks your to help him.
Input
The first line contains the single integer n (1≤ n ≤1000)-the number of contests where the C Oder participated.
The next line contains n space-separated non-negative integer numbers-they is the points which the coder H As earned. The points is given in the chronological order. All points does not exceed 10000.
Output
Print the single number-the number of amazing performances the coder have had during he whole history of participating I n the contests.
Examplesinput
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 is amazing.
"Analysis": a sequence of numbers that satisfies the number of the current number between the maximum and minimum values of the number that has occurred (strictly greater than and less than) to traverse once, maintaining the current maximum and minimum values, and then judging the count on the line.
"Code":
#include <bits/stdc++.h>using namespacestd;intn,a[1050],sum,maxx,minx;intMain () { while(cin>>n) {sum=0; CIN>>a[0];//!!!minx=maxx=a[0]; for(intI=1; i<n;i++) {cin>>A[i]; if(a[i]>Maxx) {Sum++; Maxx=A[i]; } if(a[i]<Minx) {Sum++; Minx=A[i]; }} cout<<sum<<Endl; } return 0;}
The array is bigger!
Codeforces Round #109 (Div. 2) A. I_love_%username% "Daleitai algorithm/number of maximum and minimum values that satisfy the current number in the number that has occurred"