1869. New Year Cruise
来源:互联网 发布:2016淘宝刷单违规处罚 编辑:程序博客网 时间:2024/06/06 02:53
原题链接: http://acm.timus.ru/problem.aspx?space=1&num=1869
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 i to 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
30 180 1800 0 180360 0 0
10
Problem Author: Denis Dublennykh
Problem Source: Open Ural FU Championship 2011
Problem Source: Open Ural FU Championship 2011
/* * ACM Timus Online Judge Contest 15 October 2011 * Problem H - New Year Cruise */#include <cstdio>#define MAX(a, b) ((a) > (b) ? (a) : (b))int N, A[100][100];int main(){#ifndef ONLINE_JUDGE freopen("input.txt", "rt", stdin);#endif int i, j, k, max; scanf("%d", &N); for (i = 0; i < N; i++) for (j = 0; j < N; j++) { scanf("%d", &A[i][j]); }; for (i = 0; i < N; i++) for (j = 0; j < N; j++) { if (A[i][j] == 0) continue; // Vladi -> Moscow if (i < j && j - i > 1) { for (k = i; k < j; k++) { A[k][k + 1] += A[i][j]; } } // Moscow -> Vladi else if (i > j && i - j > 1) { for (k = i; k > j; k--) { A[k][k - 1] += A[i][j]; } } }; // get maximum for each pair of stations max = 0; for (i = 0; i < N - 1; i++) { if (MAX(A[i][i + 1], A[i + 1][i]) > max) { max = MAX(A[i][i + 1], A[i + 1][i]); } } if (max % 36 == 0) max /= 36; else max = 1 + max / 36; printf("%d", max); return 0;}
- 1869. New Year Cruise
- ural 1869. New Year Cruise
- new year~~
- new year
- new year
- new year
- new year
- new year
- New Year, New Start
- New Year, New Life
- 2006 New year New hope
- Happy New Year!
- Happ New Year
- ~~New Year,My Paradise!!~~
- Happy new year!
- happy new year
- New Year Thoughts
- For a New Year
- snprintf出core问题
- 用输入法设置截屏快捷键
- HTTP 错误 404.2 - Not Found 由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面
- 如何处理刺头兵
- ecshop二次开发bug(一)
- 1869. New Year Cruise
- 黑马程序员_01_环境搭建_函数关系
- hdu4004之二分查找
- 入门一:依赖注入
- Android开发规范
- 生成器模式
- 史上最全Android开发资料:资源、UI、函数库、测试、构建全套教程
- RTP协议
- Positive predictive value