codevs 1201 最小数和最大数

http://codevs.cn/problem/1201/

1201 最小数和最大数

 

 时间限制: 1 s
 空间限制: 128000 KB
 题目等级 : 青铜 Bronze
 
 
 
题目描述 Description

输入n个数,n<=100,找到其中最小的数和最大的数

输入描述 Input Description

第一行一个整数n

接下来一行n个整数,每个整数不超过231 -1

输出描述 Output Description

最小和最大的数

样例输入 Sample Input

4

1 2 3 4

样例输出 Sample Output

1 4

数据范围及提示 Data Size & Hint

分类标签 Tags 

 
通过11 k
 
提交29 k
 
40%
通过率
Summary
AC
41%
WA
37%
RE
21%
Other
1%
  • 120251 AC
  • 108752 WA
  • 2373 TLE
  • 94 MLE
  • 60245 RE
 
  
 
分析:
 
第一次做OI的题,感觉和acm不是很一样,首先oj界面比acm界面做的华丽,会有某一题的题解和数据说明,会有个人的“等级修炼”,,,还有Pascal语言,一般acm都是多个Java,还有本题的通过率显示会和WA . TLE . MLE . RE . AC放在一块,美美的~~~
 
不多说啦,直接看题,这一题就是求最值,一般acm的oj都是a + b ,(呵呵哒)
 
AC代码:
 
 1 #include <stdio.h>
 2 #include <algorithm>
 3 #include <iostream>
 4 #include <string.h>
 5 #include <string>
 6 #include <math.h>
 7 #include <stdlib.h>
 8 #include <queue>
 9 #include <stack>
10 #include <set>
11 #include <map>
12 #include <list>
13 #include <iomanip>
14 #include <vector>
15 #pragma comment(linker, "/STACK:1024000000,1024000000")
16 #pragma warning(disable:4786)
17 
18 using namespace std;
19 
20 const int INF = 0x3f3f3f3f;
21 const int MAX = 10000 + 10;
22 const double eps = 1e-8;
23 const double PI = acos(-1.0);
24 
25 int main()
26 {
27     int n , temp;
28     while(~scanf("%d",&n))
29     {
30         int ma = -INF , mi = INF;
31         while(n --)
32         {
33             scanf("%d",&temp);
34             if(temp > ma)
35                 ma = temp;
36             if(temp < mi)
37                 mi = temp;
38         }
39         printf("%d %d
",mi , ma);
40     }
41     return 0;
42 }
View Code
 
悠游天地间 all rights reserved. © 2013 -- 1 << 64
原文地址:https://www.cnblogs.com/jeff-wgc/p/4454081.html