CF c-table Decorations

Source: Internet
Author: User

C-table Decorations
Time limit:1000ms Memory limit:262144kb 64bit IO format:%i64d &%i64u
Submit

Status

Practice

Codeforces 478C
Description
You have r red, G Green and B blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to some table shouldn ' t has the same color. What maximum number t of tables can is decorated if we know number of balloons of each color?

Your task is to write a program this for given values R, G and B would find the maximum number t of tables, that can be Dec Orated in the required manner.

Input
The single line contains three integers r, G and B (0?≤?r,?g,?b?≤?2 109)-the number of red, green and blue baloons Respe Ctively. The numbers is separated by exactly one space.

Output
Print a single integer t-the maximum number of tables so can be decorated in the required manner.

Sample Input
Input
5 4 3
Output
4
Input
1 1 1
Output
1
Input
2 3 3
Output
2
Idea: A[1],a[2],a[3] from small to large sort, if (a[1]+a[2]) *2<=a[3] Then the maximum is a[1]+a[2];
Otherwise: The maximum value is three and divisible by 3 (it can be thought that the decoration of each table is contributed by the maximum value of 2, the second big value contribution 1)

#include <iostream>#include <stdio.h>#include <string>#include <string.h>#include <algorithm>using namespace STD;typedef Long LongLl;ll a[5];intMain () { while(Cin>>a[1]>>a[2]>>a[3]) {ll sum=0; Sort (A +1, A +4);if((a[1]+a[2])*2<=a[3]) sum=a[1]+a[2];ElseSum= (a[1]+a[2]+a[3])/3;printf("%i64d\n", sum); }return 0;}

CF c-table Decorations

Related Article

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.