• CODE[VS] 2914 吹空调


    题目描述 Description

    天太热了,而且悲催的是,班上还没有空调。555~~~

    幸好,三位英语课代表A,B,C要去办公室改笔记。

    在办公室吹空调真爽,所以要尽量长的呆在办公室。

    现在有N本笔记,每本给A,B,C改的时间分别是Ai,Bi,Ci。

    三人必须一起改,每次等最慢的人改完再换下一本。且不许拖拉。

    原来所有本子都在A手上,传给B或C需要1单位时间。

    求最长时间。

    输入描述 Input Description

    正整数N

    A1~An

    B1~Bn

    C1~Cn

    输出描述 Output Description

    最长时间

    样例输入 Sample Input

    3

    3 3 3

    2 4 1

    4 5 1

    样例输出 Sample Output

    14

    数据范围及提示 Data Size & Hint

    N<=20,Ai,Bi,Ci<=100.

    为什么老做模拟题,,

    因为适合我这种头脑简单的生物。

    对,,不能老练模拟,,,

    所以,这是个模拟题。

    我一开始写的,,,所有的都要分给b和c,

    就每次都加2.

    就有了如下代码。。:

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<algorithm>
    #include<cstring>
    using namespace std;
    
    int n,ans,maxn;
    
    struct node{
        int a,b,c;
    }stu[22];
    
    bool cmp(node x,node y,node z)
    {
        return x.a <y.b <z.c ;
    }
    
    int main()
    {
        scanf("%d",&n);
        ans=n/3*2;
        for(int i=1;i<=n;++i)
            scanf("%d",&stu[i].a );
        for(int i=1;i<=n;++i)
            scanf("%d",&stu[i].b );
        for(int i=1;i<=n;++i)
            scanf("%d",&stu[i].c );
        for(int i=1;i<=n;++i)
        {
            maxn=max(stu[i].a ,max(stu[i].b ,stu[i].c ));
            ans+=maxn;
            maxn=0;
        }
        printf("%d",ans);
        return 0;
    }
    33分gg

    然而并不一定都要分给b和c

    可能a需要的时间最长,那他就不需要传递给b,c,就不用加上那额外的1了。

    ac代码:

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cmath>
     4 #include<algorithm>
     5 #include<cstring>
     6 using namespace std;
     7 
     8 int n,ans,maxn;
     9 int a[22],b[22],c[22];
    10 
    11 int main()
    12 {
    13     scanf("%d",&n);
    14     for(int i=1; i<=n; ++i)
    15         scanf("%d",&a[i] );
    16     for(int i=1; i<=n; ++i)
    17         scanf("%d",&b[i] );
    18     for(int i=1; i<=n; ++i)
    19         scanf("%d",&c[i] );
    20     for(int i=1; i<=n; ++i)
    21     {
    22         if(a[i]>b[i]&&a[i]>c[i])
    23             ans+=a[i];
    24         else ans+=max(b[i],c[i])+1;
    25     }
    26     printf("%d",ans);
    27     return 0;
    28 }
    ac
  • 相关阅读:
    hdu 5532 Almost Sorted Array(模拟)
    hdu 2612 Find a way(bfs)
    hdu 2660 Accepted Necklace(dfs)
    reactjs学习一(环境搭配react+es6+webpack热部署)
    途牛banner自动轮播
    web app开发技巧总结
    20个为前端开发者准备的文档和指南
    Github上最受关注的前端大牛 快来膜拜把!
    怎么才能成为优秀的前端开发工程师?
    Web前端知识技能大汇总
  • 原文地址:https://www.cnblogs.com/Mary-Sue/p/9165570.html
Copyright © 2020-2023  润新知