zoukankan      html  css  js  c++  java
  • Spoj-BIPCSMR16 Team Building

    To make competitive programmers of BUBT, authority decide to take regular programming contest. To make this contest more competitive and fruitful there are some rules given to balance a team:
    1. Only 1st , 2nd and 3rd year student can participate. 
    2. A team must have three members. 
    3. All the member cannot be from same year. 

    You need to find out the maximum number of teams can build up according to given rules.

    Input

    The first line of input contain an integer T (1<=T<=10000) test case. Next T line contains three positive integer X, Y and Z (1<=X, Y, Z<=2*10^9) separated by a space which denotes the number of participants from 1st, 2nd, and 3rd year student.

    Output

    You need to find out the maximum number of teams can build up according to given rules.

    Example

    Input
    2
    1 2 3
    1 12 3
    Output
    2
    4

    不能取三个同年级的,就跟这题一模一样 cf478C

    如果最大的人数比另外两种的人数之和小,就可以直接组成sum/3个

    否则全部都是2:1的方案

     1 #include<cstdio>
     2 #include<iostream>
     3 #include<cstring>
     4 #include<cstdlib>
     5 #include<algorithm>
     6 #include<cmath>
     7 #include<queue>
     8 #include<deque>
     9 #include<set>
    10 #include<map>
    11 #include<ctime>
    12 #define LL long long
    13 #define inf 0x7ffffff
    14 #define pa pair<int,int>
    15 #define mkp(a,b) make_pair(a,b)
    16 #define pi 3.1415926535897932384626433832795028841971
    17 #define mod 1000000007
    18 using namespace std;
    19 inline LL read()
    20 {
    21     LL x=0,f=1;char ch=getchar();
    22     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    23     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    24     return x*f;
    25 }
    26 int main()
    27 {
    28     int T=read();
    29     while (T--)
    30     {
    31         LL a=read(),b=read(),c=read();
    32         printf("%lld
    ",min((a+b+c)/3,min(a+b,min(b+c,c+a))));
    33     }
    34 }
    Spoj BIPCSMR16
  • 相关阅读:
    数组(array)
    亲戚(relative)
    [ZJOI2016]小星星
    P4782 【模板】2-SAT 问题
    CF1065F Up and Down the Tree
    CF1065C Make It Equal
    CF1060F Shrinking Tree
    CF1060E Sergey and Subway(点分治)
    CF1060D Social Circles
    CF1060C Maximum Subrectangle
  • 原文地址:https://www.cnblogs.com/zhber/p/7182268.html
Copyright © 2011-2022 走看看