Codeforces Round #311 (Div. 2) b. Pasha and Tea

Source: Internet
Author: User

"Topic link" click here~~

"The main idea" gives you n boy,n a girl, then w represents the maximum capacity of the teapot, and then n Cups, each with a different capacity, requiring boy's cup of tea is twice times the girl, and boy and boy capacity, girl and girl capacity, like, ask how to pour tea, Maximizing the total amount of tea

"Problem-solving ideas" This problem is very simple, the first read the question did not read, thought that each cup of tea is full, and then a think is not to take the biggest calculation. A turn, direct WA, and then carefully read the question, found that each cup of tea can choose to pour (pit ~ AH), then since the boy and Boy,girl and girl of tea, then as long as the first to find the smallest capacity and then compare it, because the boy's cup of tea is girl twice times, So the girl is the smallest.

Code:

#include <bits/stdc++.h>using namespace Std;const int n=3*1e5+10;double num[n];int main () {    int n,w;    while (scanf ("%d%d", &n,&w)!=eof)    {for        (int i=1; i<=2*n; ++i) scanf ("%lf", &num[i]);        Sort (num+1,num+1+2*n);        Double Res=min (NUM[1],NUM[N+1]/2);///////Select the minimum        res=res*3*n        after the play sequence; Res=min (res,1.0*w);        printf ("%.6f\n", res);    }    return 0;}
Res=res*3*n=res*n+res*2*n;

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Codeforces Round #311 (Div. 2) b. Pasha and Tea

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.