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);
    }
}

 

全部评论

相关推荐

06-15 02:05
已编辑
南昌航空大学 数据分析师
Eason三木:你如果想干技术岗,那几个发公众号合唱比赛的经历就去掉,优秀团员去掉,求职没用。然后CET4这种不是奖项,是技能,放到下面的专业技能里或者单独列一个英语能力。 另外好好改改你的排版,首行缩进完全没有必要,行间距好好调调,别让字和标题背景黏在一起,你下面说能做高质量PPT你得展现出来啊,你这简历排版我用PPT做的都能比你做的好。 然后自我评价,你如果要干数据工程师,抗压能力强最起码得有吧。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务