C: Sub-minor large valueProgress Bar
Time limit:0 Sec Memory limit:0 MiB
Submitted:782 correct answer:166
Title DescriptionSmall A: little B can you sing a little star?Little B: A flash of sparkle, very simple;Little A: Will you find the maximum minimum of a sequence number?
Little B: Of course, it's simple. I will also find a small value of the second big value?
Small A: Small times big value?
Small B: Sub-small value is larger than the minimum value, minus the minimum value of the remaining sequence. Second-largest value. But if there is no secondary small value, the second small value is the minimum value plus one, similarly if there is no secondary large value, the second largest value minus one;
Little A: ...Inputthe input gives a positive integer n (0<n<100) on the first line. The second line gives n integers (all of them are int) (the confused little a reminds you that this is a multi-instance yo)Outputoutput the sub-small and secondary values of this sequence (the middle space is separated, the output takes up one row)Sample inputCopy
51 2 3) 4 5
Sample outputCopy
2 4
#include <stdio.h>#include<string.h>#include<math.h>#defineINF 0x3f3f3f3f//the second minor large value cannot be equal to the minimum maximum valueintMain () {intn,fmax,fmin,smax,smin,x; while(~SCANF ("%d",&N)) {Fmax=smax=-inf; Fmin=smin=inf; while(n--) {scanf ("%d",&x); if(x>Fmax) {Smax=Fmax; Fmax=x; } Else if(x>smax&&x!=Fmax) {Smax=x; } if(x<fmin) {Smin=fmin; Fmin=x; } Else if(x<smin&&x!=fmin) {Smin=x; }} printf ("%d%d\n", Smin!=inf? smin:fmin+1, Smax!=-inf? smax:fmax-1); } return 0;}
Zznu Minor Large value (pit point can not be simply sorted, directly check the reliable)