• H


    H - New Year Cruise
    Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

    Description

    And I drank it straight down.
    In the life of Russian people there is always a place for a holiday! Even more so when several causes for celebration follow each other — New Year, Orthodox Christmas, Old New Year… People celebrate these holidays in different ways. Some of them like to be together with their family and friends, while others prefer to go for a travel. The company “Siberian Railroads” decided to combine these two variants by introducing a special cruise train “Booze” traveling along the route Vladivostok–Moscow–Vladivostok. The train would cruise once in a year only, during the New Year holidays. It would be adapted for celebrating each of the holidays up until the following holiday or until arriving to the destination.
    When the company started selling tickets for the train, they turned out to be in great demand. The sale was stopped on the third day because a train for all those wishing to go on the cruise would be too long to fit any station. The company's managers calculated the number of tickets sold for the travel between each pair of stations, and they wanted to know the number of cars in the train sufficient to accommodate all the passengers.

    Input

    The first line contains the number  n of stations where the train stops when traveling in one direction (2 ≤ n ≤ 100). The stations are numbered from 1 to  n in the order the train passes them. Vladivostok is numbered 1 and Moscow is numbered  n. In the following n lines you are given an n × n matrix with integer elements  aij. The element  aij is the number of people who have bought a ticket from station  ito station  j (0 ≤ aij ≤ 1 000; aii = 0); these people will board the train traveling from Vladivostok to Moscow if i < j and the train traveling in the opposite direction if i > j.

    Output

    Output the minimal number of cars in the train that is sufficient to accommodate all the passengers. There are exactly 36 seats in each car.

    Sample Input

    inputoutput
    3
    0 180 180
    0 0 180
    360 0 0
    
    10
    
    int t[maxn][maxn];
    int in[maxn];
    int ou[maxn];
    int main() 
    {
        //freopen("in.txt","r",stdin);
        int n;
        while(cin>>n)
        {
            repf(i,1,n)
                repf(j,1,n)
                {
                    scanf("%d",&t[i][j]);
                } 
    
            clr(in);
            clr(ou);
    
            repf(i,1,n)
            {
                repf(j,i,n)
                {
                    ou[i] += t[i][j];
                    in[j] += t[i][j];
                } 
            }
            int Maxx = 0;
            int sum = 0;
            repf(i,1,n)
            {
                sum = max(0,sum + ou[i] - in[i]);
                Maxx = max(Maxx,sum);  
            }
            clr(in);
            clr(ou);
            repd(i,n,1)
            {
                repd(j,i,1)
                {
                    ou[i] += t[i][j];
                    in[j] += t[i][j];
                } 
            }
            repd(i,n,1)
            {
                sum = max(0,sum + ou[i] - in[i]);
                Maxx = max(Maxx,sum);    
            }
            cout<<ceil(Maxx/36.0)<<endl;
        }
        return 0;
    }
     
  • 相关阅读:
    图解zookeeper FastLeader选举算法【转】
    win10 tensorflow python3*,Multiprocessing using fit_generator(pickle_safe=True) fail问题解决
    xcode从8升级到9出现的问题
    c++保存数据到TXT
    基于机器学习人脸识别face recognition具体的算法和原理
    pycharm 操作的一些设置,记录下
    ML-DL-各种资源汇总
    MATLAB实现多元线性回归预测
    【机器学习】 Matlab 2015a 自带机器学习算法汇总
    C++中嵌入python程序——命令行模式
  • 原文地址:https://www.cnblogs.com/DreamHighWithMe/p/3448364.html
Copyright © 2020-2023  润新知