codeforces——155A——I_love_\%username\%
2017-05-31 14:51
260 查看
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.
Examples
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.
以第一次为标准判断出现最大,最小值出现的次数,每次出现最大值更换最大值,反之亦然。统计最大最小值替换次数。
水过。
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.
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.
以第一次为标准判断出现最大,最小值出现的次数,每次出现最大值更换最大值,反之亦然。统计最大最小值替换次数。
水过。
#include <iostream> #include<cstring> #include<string> #include<stdio.h> #include<algorithm> #include<set> using namespace std; int main() { int n; while(~scanf("%d",&n)) { int max,min,ans=0; cin>>max; min=max; n--; while(n--) { int t; cin>>t; if(t>max) { ans++; max=t; } if(t<min) { ans++; min=t; } } cout<<ans<<endl; } return 0; }
相关文章推荐
- 155A. I_love_%username% 解题报告
- codeforces水题100道 第十九题 Codeforces Round #109 (Div. 2) A. I_love_%username% (brute force)
- Codeforces 155A I_love_%username%
- A. I_love_%username%
- I_love_%username%
- Codeforces I_love_%username%
- Action从jsp页面取值的<input id="user.pid",name="user.pid" value="huang">
- 通过LDAP获取Username
- Error creating bean with name 'userService': Injection of resource methods failed; nested exception is org.springframework.beans
- sqlplus登录oracle时ORA-01017: invalid username/password; logon denied的错误
- oracle12创建用户错误ORA-65096: 公用用户名或角色名无效 invalid common user or role name
- String整合Hibernate Hql出现user is not mapped [FROM USER WHERE username =? and password=?
- Page.User.Identity.Name获取不到结果
- ORA-01017 invalid username/password;logon denied" (密码丢失解决方案)
- here is no Action mapped for namespace [/user] and action name [user!add] associated with context pa
- This Vuser already started a transaction with the same name...解决方法
- 解决User.Identity.IsAuthenticated==false 或User.Identity.Name==string.empty的问题
- ORA-01017 invalid username/password;logon denied" (密码丢失解决方案)
- gpasswd命令 gpasswd -a user_name group_name
- 问题:docker pull 用户登陆tricky,Error response from daemon: unauthorized: incorrect username or password