zoukankan      html  css  js  c++  java
  • 贪心 Codeforces Round #273 (Div. 2) C. Table Decorations

    题目传送门

     1 /*
     2     贪心:排序后,当a[3] > 2 * (a[1] + a[2]), 可以最多的2个,其他的都是1个,ggr,ggb, ggr。。。 ans = a[1] + a[2];
     3 或先2个+1个,然后k个rgb。。。r = x + k; g = 2 * (x + z) + k; b = z + k; ans = (x + z) + k = (a[1] + a[2] + a[3]) / 3;
     4     隔了一段时间有做到这题又不会了,看别人的解题报告水平果然没有提升,以后做题要独立思考,看别人的也要完全理解并记住!
     5 */
     6 #include <cstdio>
     7 #include <algorithm>
     8 #include <cstring>
     9 #include <cmath>
    10 using namespace std;
    11  
    12 typedef long long ll;
    13 const int MAXN = 1e3 + 10;
    14 const int INF = 0x3f3f3f3f;
    15 
    16 int main(void)        //Codeforces Round #273 (Div. 2) C. Table Decorations
    17 {
    18 //    freopen ("C.in", "r", stdin);
    19 
    20     ll a[4];
    21     while (scanf ("%I64d%I64d%I64d", &a[1], &a[2], &a[3]) == 3)
    22     {
    23         sort (a+1, a+1+3);
    24         printf ("%I64d
    ",     min ((a[1] + a[2] + a[3]) / 3, a[1] + a[2]));
    25     }
    26 
    27     return 0;
    28 }
    编译人生,运行世界!
  • 相关阅读:
    d3的一些总结
    NPashaP的二分图源码部分
    python的web服务器
    d3碰撞源码分析
    测试cnblog文章内部JS
    仿淘宝 vue
    webpack散记---代码分割 和 懒加载
    webpack散记---提取公共代码
    webpack散记--Typescript
    webpack随笔2--编译ES6/ES7
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4566314.html
Copyright © 2011-2022 走看看