#12686: 求解

#### a2583669 (YuFong)

School : 國立雲林科技大學
ID : 59032
2020-03-03 18:54:27
b964. 第 1 題 成績指標 -- | From: [36.233.129.155] | Post Date : 2017-09-11 01:04

#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
int a;

vector < int > num;
while(scanf("%d",&a)){
num.clear();
if(!a)
break;

//scanf("%d",&a);
int fail_max = 0 , pass_min = 999;
for(int j=0 ; j<a ; ++j)
{
int reg;
scanf("%d",&reg);
if(reg>fail_max && reg<60)
fail_max = reg;
if(reg<pass_min && reg>=60)
pass_min = reg;
num.push_back(reg);
}
sort(num.begin(),num.end());
for(int k=0 ; k<num.size() ; ++k)
{
printf("%d ",num[k]);
}
printf("\n");
if(!fail_max)
printf("best case\n");
else
printf("%d\n",fail_max);
if(pass_min == 999)
printf("worst case\n");
else
printf("%d\n",pass_min);

}
return 0;
}

//why TLE

#12690: Re:求解

#### justinO__o (夜貓)

School : 臺北市立成功高級中學
ID : 51052
2020-02-10 20:55:50
b964. 第 1 題 成績指標 -- | From: [203.143.25.210] | Post Date : 2017-09-12 03:31

#include
#include
#include
#include
using namespace std;
int main(){
int a;

vector < int > num;
while(scanf("%d",&a)){
num.clear();
if(!a)
break;

//scanf("%d",&a);
int fail_max = 0 , pass_min = 999;
for(int j=0 ; j {
int reg;
scanf("%d",&reg);
if(reg>fail_max && reg<60)
fail_max = reg;
if(reg=60)
pass_min = reg;
num.push_back(reg);
}
sort(num.begin(),num.end());
for(int k=0 ; k<num.size() ; ++k)
{
printf("%d ",num[k]);
}
printf("\n");
if(!fail_max)
printf("best case\n");
else
printf("%d\n",fail_max);
if(pass_min == 999)
printf("worst case\n");
else
printf("%d\n",pass_min);

}
return 0;
}

//why TLE

while(scanf("%d", &a) == 1) {

// code

}

ZeroJudge Forum