zoukankan      html  css  js  c++  java
  • 万万没想到(2) 南邮NOJ2058

    万万没想到(2)

    时间限制(普通/Java) : 1000 MS/ 3000 MS          运行内存限制 : 65536 KByte
    总提交 : 123            测试通过 : 48 

    题目描述

        万万没想到,啦啦啦啦啦

        经过愉快的开场游戏之后,激动人心的签售环节终于开始了。

        根据书店与剧组安排,分别由叫兽,小爱和孔连顺分三队同时开始签售,我们不妨将其从左到右抽象成三个签售点,编号由1到3,而且平均每个签售点为一个人签名耗时1秒;

        现在,yuman作为《万万没想到》的狂热粉丝,肯定希望能获得三个人的签名。不过,yuman同时也不希望排队时间太长,所以他想找出一种最优的排队策略,使他获得这三个人的签名,而且用时最短。



    输入

    先输入一个正整数T,(1<=T<=100),表示有T组数据;

    对于每一组数据,分别输入三个整数,第i个数pi,表示当前第i个签售点有pi个人(0<=pi<=10000);

    输出

    对于每一组数据,输出一个正整数,表示在最优策略下,排队的总时间;

    样例输入

    2
    0 1 2
    3 1 2

    样例输出

    3
    4

    提示

    对于第一组样例,yuman的排队顺序是 1 -> 2 -> 3;

    对于第二组样例,yuman的排队顺序是 2 -> 3 -> 1;

    #include<iostream>
    using namespace std;
    #include<algorithm>
    int main()
    {
        int m;
        cin>>m;
        while(m--)
        {
            int a[3];
            cin>>a[0]>>a[1]>>a[2];
            int t=0;
            sort(a,a+3);
            for(int i=0;i<3;i++)
            {
                if(a[i]>=0)
                {
                    t+=a[i];
                }
                else
                {
    
                }
                t+=1;
                for(int j=i+1;j<3;j++)
                {
                    a[j]-=a[i];
                    a[j]--;
                }
            }
            cout<<t<<endl;
        }
    }
    

    窝只想说~还好只有三个签售点~~

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    LeetCode 189. Rotate Array
    LeetCode 965. Univalued Binary Tree
    LeetCode 111. Minimum Depth of Binary Tree
    LeetCode 104. Maximum Depth of Binary Tree
    Windows下MySQL的安装与配置
    LeetCode 58. Length of Last Word
    LeetCode 41. First Missing Positive
    LeetCode 283. Move Zeroes
    《蚂蚁金服11.11:支付宝和蚂蚁花呗的技术架构及实践》读后感
    删除docker下的镜像
  • 原文地址:https://www.cnblogs.com/Tobyuyu/p/4965646.html
Copyright © 2011-2022 走看看