zoukankan      html  css  js  c++  java
  • hdu 1050 (preinitilization or postcleansing, std::fill) 分类: hdoj 2015-06-18 11:33 34人阅读 评论(0) 收藏

    errors, clauses in place, logical ones, should be avoided.

    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    
    int main() {
        //freopen("input.txt","r",stdin);
        const int CorNum=201;
        int ncase, npair, to,from, first,last, res;
        int shared[CorNum]={0};
        if(scanf("%d",&ncase)!=1) return -1;
        while(ncase-- && scanf("%d",&npair)==1) {
            first=CorNum, last=0;
            while(npair--) {
                scanf("%d%d",&from,&to);
                from=(from-1)>>1; to=(to-1)>>1;
                if(from>to) std::swap(from,to);
                first=std::min(first,from); last=std::max(last,to);
                for(;from<=to;++from) ++shared[from];
            }
            for(res=0,from=first;from<=last;++from) res=std::max(res,shared[from]);
            std::fill(&shared[first],&shared[last+1],0);
            printf("%d
    ",res*10);
        }
        return 0;
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。// p.s. If in any way improment can be achieved, better performance or whatever, it will be well-appreciated to let me know, thanks in advance.

  • 相关阅读:
    CentOS/RHEL 查看用户登陆信息
    PAM
    块存储
    ECS
    SQL 基础应用
    MySQL 基础管理
    MySQL 体系结构
    JSON对象
    设置dom节点属性的代码优化
    Ext框架下的元素拖动
  • 原文地址:https://www.cnblogs.com/qeatzy/p/4716225.html
Copyright © 2011-2022 走看看