CodeForces - 1263A Sweet Problem(思维,水题)
生活随笔
收集整理的這篇文章主要介紹了
CodeForces - 1263A Sweet Problem(思维,水题)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目鏈接:點擊查看
題目大意:給出三種顏色的糖果,分別表示為r,g,b,現在Tanya每天可以吃兩個不同顏色的糖果,問最多可以吃多少天
題目分析:大水題一個,但自己真的蠢,一開始思路混亂,寫了一大堆亂七八糟的,肯定是以WA首尾
只需要簡單分類討論一下就行了,首先對于三個數值排序,我們記為mmin,mid和mmax:
代碼:
#include<iostream> #include<cstdlib> #include<string> #include<cstring> #include<cstdio> #include<algorithm> #include<climits> #include<cmath> #include<cctype> #include<stack> #include<queue> #include<list> #include<vector> #include<set> #include<map> #include<sstream> using namespace std;typedef long long LL;const int inf=0x3f3f3f3f;const int N=2e5+100;int a[5];int main() { // freopen("input.txt","r",stdin); // ios::sync_with_stdio(false);int w;cin>>w;while(w--){for(int i=1;i<=3;i++)scanf("%d",a+i);sort(a+1,a+1+3);if(a[1]+a[2]<a[3])printf("%d\n",a[1]+a[2]);elseprintf("%d\n",(a[1]+a[2]+a[3])/2);}return 0; }?
總結
以上是生活随笔為你收集整理的CodeForces - 1263A Sweet Problem(思维,水题)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CH - 0805 防线(二分+思维)
- 下一篇: POJ - 1459 Power Net