贪心 Codeforces Round #273 (Div. 2) C. Table Decorations
生活随笔
收集整理的這篇文章主要介紹了
贪心 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\n", min ((a[1] + a[2] + a[3]) / 3, a[1] + a[2])); 25 } 26 27 return 0; 28 }?
轉載于:https://www.cnblogs.com/Running-Time/p/4566314.html
總結
以上是生活随笔為你收集整理的贪心 Codeforces Round #273 (Div. 2) C. Table Decorations的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 把多个JavaScript函数绑定到on
- 下一篇: Python基础知识(1)简介