Codeforces Round #190 (Div. 2) B. Ciel and Flowers

Key or push equation.

To set the number of mixing bouquet x, F (x, y) = [(yx) / 3], the answer is f (x) = F (x, r) + F (x, g) + F (x, b ), where [] represents rounding down, guess f (x) is monotonic.

Push This equation f (x + 1) - f (x) = 1 + F (x + 1, r) -F (x, r) + F (x + 1, g) -F (x, g) + F (x + 1, b) -F (x, b).

Of F (x + 1, r) -F (x, r) Analysis: Let S = [(yx-1) / 3] - [(yx) / 3], the trouble is clearly a function of rounding, classified under discussion :

I. (yx)% 3 = 0, then S = -1, II. Else S = 0. Visible to the set T = {r, g, b}, if all belonging to t T, and (tx)% 3! = 0, then f (x + 1) -f (x) = 1, otherwise f (x +1) -f (x) <= 0.

At this time, still can not account for f (x) if monotonous. We elements T 3%, to obtain a new set of so-called modulo T '= {r', g ', b'} in, T 'values ​​of all elements in the interval [0,2] of.

I seen from the case, when f (x + 1) -f (x) = 1, so that x '= x% 3, all our t' belong to T ', there must be x'! = T ', if f ( x) a non-monotonically decreasing, then for all x, we have f (x + 1) -f (x)> = 0,

But this is impossible, because T 'is constant, and x' = x% 3, always within the [0,2] interval, such as if f (x + 1) - f (x) = 1, then | T'-x '| (|| herein refers to the size of the set) must equal 2, we have

r ', g', b 'mapped to T'-x' in this set can be found at least two fall on the same element, then the value of x + 1, or there must be x + 2 f ( x + 2) - f (x + 1)> = -1, or f (x + 3) - f (x + 2)> = -1,

When there are two points on the same map element, f (x) function is actually [y, y + 1] wandering interval, if the mapping point 3, then the f (x) function actually [y, y + 2] wandering interval, thus

We only need three consecutive number for x can take note x <= min (r, g, b).

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#include <bitset>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <assert.h>
using namespace std;
#define e exp(1.0)
typedef long long ll;
#define MAXN 100005
#define mod 998244353
#define INF 0x3f3f3f3f3f3f3f
#define fe(i,st,en) for(i = (st);i <= (en);++i)
#define fne(i,st,en) for(i = (st);i < (en);++i)
#define ri register int
#define db double
int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int li = min(r, min(g, b)), ans = 0;
    for (int i = 0; i <= min(2, li); ++i) ans = max(ans, (r - i) / 3 + (g - i) / 3 + (b - i) / 3 + i);
    cout << ans << endl;
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/zhuiyicc/p/10926695.html