多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > 綜合技術 > URAL 1296. Hyperjump(最大子序列和)

URAL 1296. Hyperjump(最大子序列和)

來源:程序員人生   發布時間:2015-03-30 08:56:29 閱讀次數:3671次

題目鏈接: http://acm.timus.ru/problem.aspx?space=1&num=1296


Developed in the beginning of XXI century, hyperjump remains the primary method of transportation for distances up to thousands parsecs. But physicists have recently discovered an amazing phenomenon. They believe the duration of the hyperjump alpha phase can be easily controlled. Alpha phase is the period when hyper-spacecraft accumulates its gravity potential. The larger is the gravity potential accumulated, the less energy is required to complete the hyperjump. Your task is to write a program, which would help pilots decide when to enter and when to leave the alpha-phase, in order for the hyperspacecraft to accumulate the largest possible gravity potential.
The most crude gravity field model (which you will have to use) yields the sequence of integers pi, which represent field intensities at different moments in time. According to this model, if the alpha-phase begins at moment i and ends at moment j, then the value of gravity potential accumulated will be equal to the sum of sequence elements at places from i-th to j-th inclusive.

Input

The first line of the input contains an integer N being the number of elements in the intensity values sequence (0 ≤ N ≤ 60000). Next N lines specify sequence elements, each line containing a single integer pi (?30000 ≤ pi ≤ 30000).

Output

The only line of output contains the largest possible value of the gravity potential that can be accumulated by a hyperspacecraft during the alpha phase. You should assume that the initial gravity potential of a hyperspacecraft is equal to zero.

Samples

input output
10 31 ⑷1 59 26 ⑸3 58 97 ⑼3 ⑵3 84
187
3 ⑴ ⑸ ⑹
0

PS:

如果最小和小于零 ,輸出零!

代碼以下:

#include <cstdio> int main() { int n; int a[60047]; while(~scanf("%d",&n)) { for(int i = 0; i < n; i++) { scanf("%d",&a[i]); } int maxx = 0, sum = 0; for(int i = 0; i < n; i++) { sum+=a[i]; if(sum <= 0) { sum = 0; } if(sum > maxx) { maxx = sum; } } printf("%d ",maxx); } return 0; }


生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 亚洲精品第一区二区在线 | 一级特黄aa大片欧美网站 | 多人伦交性欧美在线观看 | 日韩一级片在线免费观看 | 成年视频xxxxx在线网站 | 欧美激情xxxx性bbbb | 91精品国产闺蜜国产在线闺蜜 | 亚洲a影院| 小说区图片区综合久久88 | 日本一区毛片免费观看 | 五月网 | 亚洲精品乱码久久久久久蜜桃 | 一区二区三区中文国产亚洲 | 波多野结衣中文字幕在线播放 | 性xxxxx外性hd| 国产香蕉一区二区精品视频 | 日本免费在线一区 | 无人区理论片手机看片 | 激情五月婷婷网 | 成人精品一区二区久久久 | 欧美xxxx喷潮 | 欧美a级v片不卡在线观看 | 久久精品中文 | 午夜网站视频 | 精品伊人久久大香线蕉网站 | 国产亚洲精品一区二区在线观看 | 午夜宅男在线视频 | 亚洲精品蜜桃久久久久久 | 97精品伊人久久久大香线焦 | 2019在线亚洲成年视频网站 | 欧美v片 | 亚洲精品久久久久久久久久久网站 | 日本成人在线免费 | 日韩一级在线播放免费观看 | 老司机成人在线视频 | 最近高清中文在线国语视频 | 秋霞毛片 | 国产免费一级高清淫日本片 | 伊人333| 波多野结衣在线观看免费区 | 久久婷婷五月综合色丁香 |