设为首页 加入收藏

TOP

Codeforces Round #311 (Div. 2)(三)
2015-11-21 00:58:24 来源: 作者: 【 】 浏览:8
Tags:Codeforces Round #311 Div.
它的min值(同时也要<=max值),也就是说每个奖状都必须有人获奖。

想法:

暴力分类就好

?

#include
  
   
#include
   
     #include
    
      #include
     
       #include
       using namespace std; #define maxn 3333333 int main(){ int n; int min[4],max[4]; scanf(%d,&n); for(int i=1;i<=3;i++){ scanf(%d%d,&min[i],&max[i]); } int sum=0; sum=n-(min[2]+min[3]); if(sum>max[1]){ printf(%d ,max[1]); int sum2=n-max[1]-min[3]; if(sum2>max[2]) { printf(%d ,max[2]); int sum3=n-max[2]-max[1]; printf(%d ,sum3); } else printf(%d %d ,sum2,min[3]); } else printf(%d %d %d ,sum,min[2],min[3]); }
     
    
   
  

?

B. Pasha and Tea time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.

It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows:

  • Pasha can boil the teapot exactly once by pouring there at most w milliliters of water;
  • Pasha pours the same amount of water to each girl;
  • Pasha pours the same amount of water to each boy;
  • if each girl gets x milliliters of water, then each boy gets 2x milliliters of water.

    In the other words, each boy should get two times more water than each girl does.

    Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends.

    Input

    The first line of the input contains two integers, n and w (1?≤?n?≤?105, 1?≤?w?≤?109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters.

    The second line of the input contains the sequence of integers ai (1?≤?ai?≤?109, 1?≤?i?≤?2n) — the capacities of Pasha's tea cups in milliliters.

    Output

    Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10?-?6.

    Sample test(s) input
    2 4
    1 1 1 1
    
    output
    3
    input
    3 18
    4 4 4 2 2 2
    
    output
    18
    input
    1 5
    2 3
    
    output
    4.5
    题意:

    ?

    xx有一个容量为w升的水壶(他最多只有w升水,因为只能煮一次水,题中说的),然后总共有2n个人来参加他的party。

    xx倒水有如下规则:

    1)女孩子中所倒的水量是相同的

    2)男孩子中所到的水量也是相同的

    3)男孩子的获得水量是女孩子的2倍

    然后输出一个实数,问你在满足上面的条件下,这2n个人他们所能获得的最多的水量是多少

    题解:

    其实就是列简单的方程,然后求出约束条件就好(水题一枚~

    哦,对了,最后好多人说都卡了精度,那么最后输出.7lf就好

    ?

    #include
        
         
    #include
         
           #include
          
            #include
           
             #include
             using namespace std; #define maxn 111111 #define inf 999999999 __int64 a[maxn*2]; int main(){ __int64 n,w; scanf(%I64d%I64d,&n,&w); for(int i=0;i<2*n;i++){ scanf(%I64d,&a[i]); } sort(a,a+2*n); int min1=inf,min2=inf; for(int i=0;i
             
               现在终于成为了expert。。。我一定还会再上去的,加油,hades!!
              

    ?

    ?

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇LintCode 字符串查找 下一篇[Leetcode]-Palindrome Number

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: