天南之城的后花园

记录精彩的程序人生

文章

PAT 1008 电梯

1008 Elevator The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop. 我们城市最高的建筑只有一台电梯。有一个请求列表由 N 个正整数组成,这些数字指定电梯停在哪些楼层,按指定的顺序。电梯每上升一层需要 6 秒钟,每下降一层需要 4 秒钟。电梯每停留一个楼层需要 5 秒钟。 For a given request list, you are to compute the total ....

PAT 1007 最大子序列和

1007 Maximum Subsequence Sum Given a sequence of K integers { N1, N2, ..., N**K }. A continuous subsequence is defined to be { N**i, N**i+1, ..., N**j } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. For example, given sequence { -2, 11, -4, 13, -5, -2 }, its maximum subsequence is { 11, -4, 13 } with the largest sum being 20. Now you are supposed to find the largest sum, together with the first and the last numbers of the maximum ....

记录精彩的程序人生

© 2025 天南之城的后花园

Powered by Bolo
Theme bolo-sakura by Mashiro
浏览 50969 文章 43 评论 11
蜀ICP备2023008301号

主题 | Theme