Zznu Small times large value (pit point can not be simply sorted, directly check the reliable)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.