155A. I_love_%username% 解题报告
2012-02-25 12:11
274 查看
A. I_love_%username%
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard 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.
Sample test(s)
input
output
input
output
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.
=======
其实。一句概括:只要比前面数最大数还大或最小数还小 便 inc(ans);
View Code
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard 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.
Sample test(s)
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.
=======
其实。一句概括:只要比前面数最大数还大或最小数还小 便 inc(ans);
View Code
program A; var i,n,m,max,min,ans:longint; Begin readln(n); read(m); max:=m; min:=m; ans:=0; for i:=2 to n do begin read(m); if (m>max) or (m<min) then begin inc(ans); if m<min then min:=m; if m>max then max:=m; end; end; writeln(ans); End.
相关文章推荐
- codeforces——155A——I_love_\%username\%
- Pku acm 2752 Seek the Name, Seek the Fame数据结构题目解题报告(二十)----kmp算法
- I_love_%username%
- hdu 4409 Family Name List 金华赛区1010 (解题报告)
- E - I Love You Too解题报告(陈渊)
- E - I Love You Too解题报告(张宇)
- A. I_love_%username%
- POJ2752 Seek the Name, Seek the Fame 解题报告【字符串】【KMP】
- USACO Section 1.2 Name That Number 解题报告
- HDU 4730 We Love MOE Girls 解题报告
- codeforces水题100道 第十九题 Codeforces Round #109 (Div. 2) A. I_love_%username% (brute force)
- E - I Love You Too解题报告
- Codeforces 155A I_love_%username%
- Pku acm 2752 Seek the Name, Seek the Fame数据结构题目解题报告(二十)----kmp算法
- usaco Name That Number 解题报告
- Codeforces I_love_%username%
- USACO Section1.2 Name That Number 解题报告
- hdu 1875 畅通工程再续 解题报告
- [BZOJ2809&1455&1367]解题报告|可并堆
- [bzoj4544]椭圆上的整点 解题报告