• Codeforces 1236A. Stones


    传送门

    注意到两种操作都要消耗中间的石头,并且两种操作每次都会得到 $3$ 个石头

    那么显然优先做操作二是最优的,因为操作二只会消耗中间堆的一个石头

    如果有剩下再进行操作 $1$ ,那么可以保证总操作次数最大,即答案最大

    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    #include<cmath>
    using namespace std;
    typedef long long ll;
    inline int read()
    {
        int x=0,f=1; char ch=getchar();
        while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
        while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
        return x*f;
    }
    int main()
    {
        int T=read();
        while(T--)
        {
            int a=read(),b=read(),c=read(),ans=0;
            int t=min(b,c/2); ans+=t*3; b-=t;
            t=min(b/2,a); ans+=t*3;
            printf("%d
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    论语言思维的差异
    lua经典问题
    跳槽的故事
    未来一年计划
    腾讯面试题 找重复的数
    nodejs学习
    node记录
    mysql 常用总结
    ubuntu 服务器搭建汇总
    ubuntu下安装golang
  • 原文地址:https://www.cnblogs.com/LLTYYC/p/11699175.html
Copyright © 2020-2023  润新知