代码使用了美丽的 LATEX 渲染,使用 long long 为个人习惯,可通过本题数据。
001 | #include<bits/stdc++.h>
002 | #define int long long
003 | #define N 200005
004 | using namespace std;
005 |
006 | int T;
007 | int x,y,z;
008 | int cnt,num;
009 |
010 | signed main()
011 | {
012 | cin>>T;
013 | while(T--)
014 | {
015 | scanf("%lld%lld%lld",&x,&y,&z);
016 | num=0;
017 | num+=x/3;
018 | x%=3; // 111
019 |
020 | cnt=min(x,y/2);
021 | num+=cnt;
022 | x-=cnt,y-=cnt*2;
023 | // 122
024 |
025 | cnt=min(x,z/2);
026 | num+=cnt;
027 | x-=cnt,z-=cnt*2;
028 | // 133
029 |
030 | cnt=min(y/2,z);
031 | num+=cnt;
032 | z-=cnt,y-=cnt*2;
033 | // 223
034 |
035 | cnt=min(y,z/2);
036 | num+=cnt;
037 | y-=cnt,z-=cnt*2;
038 | // 233
039 |
040 | num+=y/3;
041 | y%=3; // 222
042 | num+=z/3;
043 | z%=3; // 333
044 | printf("%lld\n",num);
045 | }
046 | return 0;
047 | }
048 |
049 | /*
050 |
051 | 1 1 1
052 | 2 2 2
053 | 3 3 3
054 | 1 2 2
055 | 2 2 3
056 | 2 3 3
057 | 1 3 3
058 |
059 | */