joj1059
2011-08-29 09:11
211 查看
1059: Mary
Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
---|---|---|---|---|---|
3s | 8192K | 2289 | 1035 | Standard |
class is and what the highest score of all classes is. But there are too many students take the examination and Mary is too lazy indeed. So she asks you, an expert on programming, to help her solve the problem.
Input Specification
The input consists of several blocks one by one. Each block represents a class, consisting of several lines. Each line of a block consists of a positive integer s, where s<=100, designating a certain student's score of the class. A 0 marks the end of theblock. A -1 marks the end of the input. For example,
60 <-- a student's score of class 1
99 <-- another student's score of class 1
85 <-- the last student's score of class 1
0 <-- end of class 1
59 <-- a student's score of class 2
94 <-- another student's score of class 2
0 <-- end of class 2
-1 <-- end of input
Output Specification
You should output the maximum score of each class in the order of classes given in the input. And then, you should also output the maximum score of all classes and the class where the maximum score appears for the first time. For the example above, you shouldmake the output like this:
99 <-- maximum score of class 1
94 <-- maximum score of class 2
99 At Class 1 <-- maximum score of class 1 and class 2
Sample Input
60 99 85 0 59 94 0 -1
Sample Output
99 94 99 At Class 1
Problem Source: 1st JOJ Cup Online VContest Warmup Problem
This problem is used for contest:
75
Submit /
Problem List / Status /
Discuss
Problem Set with Online Judge System Version 3.12
Jilin University
Developed by skywind,
SIYEE
#include<cstdio>
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int allmax=-1;
int singlemax=-1;
int score;
int singleclass=1 ;
int maxclass;
while(1)
{
scanf("%d",&score);
if(score>singlemax)
{
singlemax=score;
if(score>allmax)
{
allmax=score;
maxclass=singleclass;
}
}
if(score==0)
{
++singleclass;
printf("%d\n",singlemax);
singlemax=-1;
}
if(score==-1)
{
printf("%d At Class %d\n",allmax,maxclass);
break;
}
}
return 0;
}
相关文章推荐
- joj 儿死三八
- JOJ 1106 Complicated Expressions
- JOJ 1063: A Funny Game 解题报告
- joj 1551:Factorial Frequencies
- UVa 624 CD && joj 1387 CD 背包问题
- joj1995
- JOJ 2656: 霍格瓦兹魔法阵 //最小割
- joj 1031 Hanoi Tower Troubles Again!解题报告
- joj 2575: Moveable quadrangle with three edges ()
- joj2075
- JOJ2519 Find the longest section(位运算 +(前缀和?))
- joj 2732: Cow XOR 求最大异或段
- joj2000
- joj 2536
- joj 2620: Count Square 状态压缩DP N*M的0,1方格,每一个2*2的小方格有一个价值,求整个方格的最大价值
- JOJ1040:Trees(卡特兰数+递归)
- joj 1189
- JOJ1490:487-3279
- 【多重背包】HDU 1059
- joj2608 石子