C. Gourmet Cat

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Polycarp has a cat and his cat is a real gourmet! Dependent on a day of the week he eats certain type of food:

  • on Mondays, Thursdays and Sundays he eats fish food;
  • on Tuesdays and Saturdays he eats rabbit stew;
  • on other days of week he eats chicken stake.

Polycarp plans to go on a trip and already packed his backpack. His backpack contains:

  • a
  • daily rations of fish food;
  • b
  • daily rations of rabbit stew;
  • c
  • daily rations of chicken stakes.

Polycarp has to choose such day of the week to start his trip that his cat can eat without additional food purchases as long as possible. Print the maximum number of days the cat can eat in a trip without additional food purchases, if Polycarp chooses the day of the week to start his trip optimally.

Input

The first line of the input contains three positive integers a

, b and c (1≤a,b,c≤7⋅108

) — the number of daily rations of fish food, rabbit stew and chicken stakes in Polycarps backpack correspondingly.

Output

Print the maximum number of days the cat can eat in a trip without additional food purchases, if Polycarp chooses the day of the week to start his trip optimally.

Examples

Input

Copy

2 1 1

Output

Copy

4

Input

Copy

3 2 2

Output

Copy

7

Input

Copy

1 100 1

Output

Copy

3

Input

Copy

30 20 10

Output

Copy

39

ac代码

 By jswwsj, contest: Codeforces Round #552 (Div. 3), problem: (C) Gourmet Cat, Accepted, #

#include<stdio.h>
#include<algorithm>
#include<cstring>
using namespace std;
#define ll long long
int maxx=0;
void dfs(int day,int sum,int a,int b,int c)
{
    if(a==-1||b==-1||c==-1||sum>7){
        maxx=max(maxx,sum-1);
        return;
    }
    if(day>7) day=1;
    if(day==1||day==4||day==7)
    {
        //printf("day=%d sum=%d a=%d b=%d c=%d\n",day,sum,a,b,c);
        dfs(day+1,sum+1,a-1,b,c);
    }
    else if(day==2||day==6)
    {
        //printf("day=%d sum=%d a=%d b=%d c=%d\n",day,sum,a,b,c);
        dfs(day+1,sum+1,a,b-1,c);
    }
    else
    {
        //printf("day=%d sum=%d a=%d b=%d c=%d\n",day,sum,a,b,c);
        dfs(day+1,sum+1,a,b,c-1);
    }
}
int main()
{
    int a,b,c;
    while(scanf("%d %d %d",&a,&b,&c)!=EOF)
    {
        maxx=0;
        int d[10]={0},sum=0;
        d[1]=a/3;d[2]=b/2;d[3]=c/2;
        sort(d+1,d+4);
        sum+=7*d[1];
        a-=d[1]*3;
        b-=d[1]*2;
        c-=d[1]*2;
       // printf("sum=%d a=%d b=%d c=%d\n",sum,)
        //dfs(7,1,a,b,c);
        for(int i=1;i<=7;i++)
        {
            dfs(i,0,a,b,c);
        }
        printf("%d\n",sum+maxx);
    }
}

 

全部评论

相关推荐

野猪不是猪🐗:把你的学校加黑,加粗,斜体,下划线,描边,内阴影,内发光,投影,外发光,再上渐变色,居中,放大到最大字号,再把简历里其它内容删了,就行了
点赞 评论 收藏
分享
02-05 08:18
四川大学 Java
在思考的熊熊很讨厌吃香菜:不是,我门头沟学院呢?这都没排上?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务