#12686: 求解


a2583669 (YuFong)

School : 國立雲林科技大學
ID : 59032
IP address : [223.138.238.218]
Last Login :
2020-03-03 18:54:27
b964. 第 1 題 成績指標 -- APCS大學程式設計先修檢測(2016/03/05) | 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
IP address : [223.137.206.97]
Last Login :
2020-02-10 20:55:50
b964. 第 1 題 成績指標 -- APCS大學程式設計先修檢測(2016/03/05) | 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

}

 

然後他嚴格比對

記得行末不要多於空白 0u0

 
ZeroJudge Forum