题解 CF1091A 【New Year and the Christmas Ornament】

小黑AWM

2018-12-31 18:18:33

Solution

私以为是一道很简单的题,可是比赛当日竟有很多人FST了。 我们发现当需要满足$y + 1 = b,\space b + 1 = r$时,装饰的总数就是$3(y+1)\space or\space 3b\space or\space 3(a-1)$因为我们选择方案的时候必须保证能够实现,所以只需选出y+1, b, a-1中的最小值*3就是答案。 ```cpp #include <cstdio> #include <iostream> using namespace std; int a, b, c, ans; int min(int a, int b){ return a<b?a:b; } int main(){ cin >> a >> b >> c; cout << 3 * min(a+1, min(b, c-1)); return 0; } ```