322B - Ciel and Flowers - CodeForces Solution


combinatorics math *1600

Please click on ads to support us..

Python Code:

r,g,b = map(int,input().split())

r2 = r%3
g2 = g%3
b2 = b%3
s  = r//3+g//3+b//3 + min(r2,g2,b2)
if ((r2+1)*(g2+1)*(b2+1) == 9) and (r*g*b != 0):
    s += 1
print(int(s))

C++ Code:

 #include<cstring>
    #define push_back pb
    #define push_front pf
    #define first F
    #define second S
    #include <bits/stdc++.h>
    #include <string>
    #define all(a) a.begin(), a.end()
    #define allr(a) a.rbegin(), a.rend()
    #include <iostream>
#include <cmath>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    const ll N = 1e5;
    const ll INF =1e10;
    const ll M= 1e9+7;
    map<char,ll>mp,bng;
    ll gcd(ll a,ll b){
        if(a==0 || b==0) return a+b;
        return gcd(b,a%b);
    }
//    ll pown(ll n, ll p){
//
//        if (p==0)
//            return 1;
//        ll tmp=(pown(n,p/2))%mod;
//        if(p%2==0){
//            ll pw=(tmp*tmp)%mod;
//            return pw;
//        }
//        else{
//            ll pw=(((n*tmp)%mod)*tmp)%mod;
//            return pw;
//        }
//    }
//    ll num[N];
//    set<ll>s;
//    vector<ll>primes;
//    void seive(){
//        num[2]=2;
//        for(int i = 3;i<N;i+=2){
//            num[i]=i;
//        }
//        for(int i = 3;i*i<N;i++){
//            if(num[i]==i){
//                for(int j = i*i;j<N;j+=i){
//                    num[j]=0;
//                }
//            }
//        }
//        for(int i = 2;i<N;i++){
//            if(num[i]==i){
//                primes.pb(i);
//            }
//        }
//    }
//    bool is_prime(ll n){
//        for(int i = 2;i*i<=n;i++){
//            if(n%i==0){
//                return false;
//            }
//        }
//        return true;
//    }
    ll lcm(ll a,ll b){
        ll g = gcd(a,b);
        ll p = a/g;
        ll q = b/g;
        return p*q*g;
    }

    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        ll a,b,c;
        cin>>a>>b>>c;
        ll mn = min({a,b,c});
        ll ans=0;
        if(a==b && c==b){
            cout<<a<<endl;
        }
        else{
            for(int i = 0;i<=min(3LL,mn);i++){
                ll tmans=i;
                ll p = a-i;
                ll q = b-i;
                ll r = c-i;
                tmans += (p/3)+(q/3)+(r/3);
                ans = max(ans,tmans);
            }
            cout<<ans<<endl;
        }






        return 0;
    }


Comments

Submit
0 Comments
More Questions

13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number
Lexical Sorting Reloaded
1514A - Perfectly Imperfect Array
580A- Kefa and First Steps
1472B- Fair Division