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

 

全部评论

相关推荐

09-14 17:23
门头沟学院
故事和酒66:所以说副业很重要,程序员干到40岁,再怎么也赚300万了,吃吃利息也够活下去
点赞 评论 收藏
分享
08-12 09:16
Java
牛客38753147...:后端的竞争者一届比一届卷,前两年非985还很多,一段大厂实习就已经非常优秀了。 现在985硕多如狗,人手一段大厂实习,而且腾讯和百度今年都宣布实习扩招了一倍不止,越来越多的人从本一研一就开始刷实习,信息差也基本没有了。可以预见的,以后只会越来越卷。
投递快手等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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