• 【noip 2016】 蚯蚓(earthworm)


    100分程序,写了2天+1小时
    →题目在这里←
    大神就是厉害……写的程序居然看都看不懂,还有就是cena上过了但是luogu上一直是恶心的TLE
    首先是考虑p=0时,数组大小开到了1100000,然后就是WA,改成了9100000之后终于坑到50分,然后开始考虑p≠0,经过神犇程序的一番洗脑,终于发现p=0和p≠0的区别就是不等于的时候需要处理时加上长的那一部分,处理完之后再减去,输出时再加上,写完之后有一种能AC的感觉,但是评测的时候发现非常尴尬,居然没有AC,然后开始一句一句的对比,发现忘记初始化了……
    que_0,que_1,que_2是要初始化的,初始化为最小值,终于AC了,很开心的交到洛谷上,结果才90,两个TLE,后来才知道long long很浪费时间,所以要减少longlong的数量,就AC了

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    using std::sort;
    int head_0=1,head_1=1,head_2=1;
    int tail_0,tail_1,tail_2;
    long long que_0[9100000],que_1[9100000],que_2[9100000];
    long long n,m,q,u,v,t;
    int comp(long long ti,long long bi)
    {
        if(ti>bi) return 1;
        return 0;
    }
    int max(long long a,long long b,long long c)
    {
        if(a<b)
            if(b<c)
            {
                head_2++;
                return c;
            }
            else
            {
                head_1++;
                return b;
            }
        else
            if(a>c)
            {
                head_0++;
                return a;
            }
            else
            {
                head_2++;
                return c;
            }
    }
    int main()
    {
        freopen("earthworm.in","r",stdin);
        freopen("earthworm.ans","w",stdout); 
        cin>>n>>m>>q>>u>>v>>t;
        memset(que_0,128,sizeof(que_0));
        memset(que_1,128,sizeof(que_1));
        memset(que_2,128,sizeof(que_2));
        tail_0=n;
        for(int i=1;i<=n;i++)
            scanf("%lld",&que_0[i]);
        sort(que_0+1,que_0+n+1,comp);
        for(int i=1;i<=m;i++)
        {
            long long x,x1,x2;
            x=max(que_0[head_0],que_1[head_1],que_2[head_2]);
            x+=(i-1)*q;
            que_1[i]=x*u/v-i*q;             //减去这段时间增长的部分
            que_2[i]=x-x*u/v-i*q;
            if(i%t==0)
                printf("%lld ",x);
        }
        printf("
    ");
        for(int i=1,x;i<=n+m;i++)
        {
            x=max(que_0[head_0],que_1[head_1],que_2[head_2]);
            if(i%t==0)  printf("%d ",x+m*q);       //x+m*q 加上增长的部分
        }
        return 0;
    }
  • 相关阅读:
    jeos没有消亡,但看 debian 的 netinst .iso格式,那就是jeos的系统!
    ubuntu-14.04.x-desktop-amd64.iso:安装Oracle11gR2
    ubuntu-16.04.1-desktop-amd64.iso:ubuntu-16.04.1-desktop-amd64:安装Oracle11gR2
    JDBC 基础
    How to check for null/empty/whitespace values with a single test?
    STRING DELIMITED BY SIZE
    分行符
    甲醛超标
    notepad++ 去空行
    shell脚本中的set -e和set -o pipefail
  • 原文地址:https://www.cnblogs.com/oiersyp/p/6241636.html
Copyright © 2020-2023  润新知