贪心 Codeforces Round #273 (Div. 2) C. Table Decorations
生活随笔
收集整理的這篇文章主要介紹了
贪心 Codeforces Round #273 (Div. 2) C. Table Decorations
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?
題目傳送門(mén)
1 /* 2 貪心:排序后,當(dāng)a[3] > 2 * (a[1] + a[2]), 可以最多的2個(gè),其他的都是1個(gè),ggr,ggb, ggr。。。 ans = a[1] + a[2]; 3 或先2個(gè)+1個(gè),然后k個(gè)rgb。。。r = x + k; g = 2 * (x + z) + k; b = z + k; ans = (x + z) + k = (a[1] + a[2] + a[3]) / 3; 4 隔了一段時(shí)間有做到這題又不會(huì)了,看別人的解題報(bào)告水平果然沒(méi)有提升,以后做題要獨(dú)立思考,看別人的也要完全理解并記住! 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 }?
轉(zhuǎn)載于:https://www.cnblogs.com/Running-Time/p/4566314.html
總結(jié)
以上是生活随笔為你收集整理的贪心 Codeforces Round #273 (Div. 2) C. Table Decorations的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 把多个JavaScript函数绑定到on
- 下一篇: model里使用汉字页面崩掉