- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int x;
- cin>>x;
- int s[x];
- for(int i=0;i<x;i++){
- cin>>s[i];
- }
- sort(s,s+x);
- for(int i=0;i<x-1;i++){
- cout<<s[i]<<" ";
- }
- cout<<s[x-1]<<endl;
- if(x==1){
- if(s[0]>59){
- cout<<"best case"<<endl;
- }else{
- cout<<s[0]<<endl;
- }
- }else{
- if(s[0]>59){
- cout<<"best case"<<endl;
- }else{
- if(s[x-1]<60){
- cout<<s[x-1]<<endl;
- }else{
- for(int i=0;i<x;i++){
- if(s[i]>59){
- cout<<s[i-1]<<endl;
- break;
- }
- }
- }
- }
- }
- if(x==1){
- if(s[0]<60){
- cout<<"worst case"<<endl;
- }else{
- cout<<s[0]<<endl;
- }
- }else{
- if(s[x-1]<60){
- cout<<"worst case"<<endl;
- }else{
- if(s[0]>60){
- cout<<s[0]<<endl;
- }else{
- for(int i=x-1;i>=0;i--){
- if(s[i]<60){
- cout<<s[i+1]<<endl;
- break;
- }
- }
- }
- }
- }
- return 0;
- }
複製代碼 |