zoukankan      html  css  js  c++  java
  • 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;
    }
     
  • 相关阅读:
    计算机网络原理精讲第一章--基本介绍
    tensorflow基础【8】-优化器
    tensorflow基础【7】-loss function
    循环神经网络(五)-LSTM进阶
    python23的区别-日常记录
    python 多版本共存
    再谈权重共享
    循环神经网络(四)-LSTM
    循环神经网络(二)-极其详细的推导BPTT
    链式法则玩转反向传播
  • 原文地址:https://www.cnblogs.com/DreamHighWithMe/p/3448364.html
Copyright © 2011-2022 走看看