Codeforces Round #622 (Div. 2)
http://codeforces.com/contest/1313
A - Fast Food Restaurant
#include<bits/stdc++.h>
using namespace std;
int t,a[3];
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&a[0],&a[1],&a[2]);
int ans = 0;
sort(a,a+3);
for(int i = 0;i < 3;++i)
if(a[i])
++ans,--a[i];
if(a[0] && a[2])
++ans,--a[0],--a[2];
if(a[1] && a[2])
++ans,--a[1],--a[2];
if(a[0] && a[1])
++ans,--a[0],--a[1];
if(a[0] && a[1] && a[2])
++ans;
printf("%d\n",ans);
}
return 0;
}
B - Different Rules
思路:最大尽可能凑a+b,最小尽可能凑a+b+1
#include<bits/stdc++.h>
using namespace std;
int t,n,a,b;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&n,&a,&b);
int ans1 = 0,ans2 = 0;
if(a > b)
swap(a,b);
ans2 = min(a-1,n-b) + min(b-1,n-a) + min(max(0,a-1-min(a-1,n-b)),max(0,b-1-min(b-1,n-a)));
if(a == n && b != n)
ans1 = n - 1 - min(n-b-1,a-1);
else if(a != n && b == n)
ans1 = n - 1 - min(n-a-1,b-1);
else if(a == n && b == n)
ans1 = n-1;
else
ans1 = n - 1 - min(n-a-1,b-1) - min(n-b-1,a-1) - min(max(0,n-a-min(n-a-1,b-1)),max(0,n-b-min(n-b-1,a-1)));
printf("%d %d\n",ans1+1,ans2+1);
}
return 0;
}