zoukankan      html  css  js  c++  java
  • 2016 noip 蚯蚓(earthworm)模板

    地址在这
    这道题一开始我没有附初值,否则有负的情况。
    longlong超时。。
    数组开小 。。
    最后虽然过了,但时间总是卡到1s,非常令人不解。
    以后做题要仔细,不要忘记一些最基本的错误。

    #include<cstdio>
    #include<iostream>
    #include<string>
    #include<cstring>
    #include<algorithm>
    #include<cmath>
    using namespace std;
    int n,m,q,t;
    int u,v;
    int a[9999999];
    int b[9999999];
    int h1=1,h2=2,h3=2;
    int c[9999999];
    int comp(const int &a,const int &b)
    {
        if(a>b) return 1;
        else return 0;
    }
    
    int main()
    {
    
       // freopen("earthworm.in","r",stdin);
       //    freopen("earthworm.out","w",stdout);
        scanf("%d%d%d%d%d%d",&n,&m,&q,&u,&v,&t);
        memset(a,128,sizeof(a));
        memset(b,128,sizeof(b));
        memset(c,128,sizeof(c));
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        sort(a+1,a+n+1,comp);
        for(int i=1;i<=m;i++)
        {
            long long x=max(a[h1],max(b[h2],c[h3]));
            int y;
            if(a[h1]==x) h1++;
            else if(b[h2]==x) h2++;
            else  h3++; 
            x=x+q*(i-1); 
            if(i%t==0)printf("%lld ",x);
            b[i+1]=x*u/v-q*i;
            c[i+1]=x-x*u/v-q*i;
        }
        printf("
    ");
        for(int i=1;i<=n+m;i++)
        {
            long long x=max(a[h1],max(b[h2],c[h3]));
            if(a[h1]==x) h1++;    
            else if(b[h2]==x) h2++;
            else  h3++;
            if(i%t==0) printf("%lld ",x+q*m); 
        }
    
    
       // fclose(stdin);
       // fclose(stdout);
        return 0;
    }
  • 相关阅读:
    获取指定字符传的长度或者高度
    检测身份证号码是否合法
    tabbar添加小红点
    单例的简单构造
    iOS程序内发短信
    多项式加法运算 使用链表实现
    链表的数组实现
    使用链表实现堆栈
    使用链表实现堆栈
    求最大子列和的几种方法
  • 原文地址:https://www.cnblogs.com/wspl98765/p/6819910.html
Copyright © 2011-2022 走看看