H - Gourmet Cat CodeForces - 1154C (思维)

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:

  • aa daily rations of fish food;
  • bb daily rations of rabbit stew;
  • cc 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 aa, bb and cc (1≤a,b,c≤7⋅1081≤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

2 1 1

Output

4

Input

3 2 2

Output

7

Input

1 100 1

Output

3

Input

30 20 10

Output

39

Note

In the first example the best day for start of the trip is Sunday. In this case, during Sunday and Monday the cat will eat fish food, during Tuesday — rabbit stewand during Wednesday — chicken stake. So, after four days of the trip all food will be eaten.

In the second example Polycarp can start his trip in any day of the week. In any case there are food supplies only for one week in Polycarps backpack.

In the third example Polycarp can start his trip in any day, excluding Wednesday, Saturday and Sunday. In this case, the cat will eat three different dishes in three days. Nevertheless that after three days of a trip there will be 9999 portions of rabbit stew in a backpack, can cannot eat anything in fourth day of a trip.

代码:


//Full of love and hope for life

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
//https://paste.ubuntu.com/
//https://www.cnblogs.com/zzrturist/    //博客园
//https://blog.youkuaiyun.com/qq_44134712     //csdn

using namespace std;
const int N=5e3+10;
typedef long long ll;
const int mod=1e9+7;

int v[8]={1,2,3,1,3,2,1};

int main()
{
    int a,b,c;
    int mi;
    cin >> a >> b >> c;
    mi=min(a/3,min(b/2,c/2));
    int sum=mi*7;
    a-=3*mi;
    b-=2*mi;
    c-=2*mi;
    int ma=0;
    for(int i=0;i<7;i++){
        int x=a;
        int y=b;
        int z=c;
        int t=0;
        for(int j=i;j<i+7;j++){
            if(v[j%7]==1){
                if(x>=1){
                    t++;
                    x--;
                }
                else{
                    break;
                }
            }
            if(v[j%7]==2){
                if(y>=1){
                    t++;
                    y--;
                }
                else{
                    break;
                }
            }
            if(v[j%7]==3){
                if(z>=1){
                    t++;
                    z--;
                }
                else{
                    break;
                }
            }
        }
        ma=max(ma,t);
    }
    cout << ma+sum;
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ZZ --瑞 hopeACMer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值