Nyoj 739 stupid question 4

Source: Internet
Author: User
Dummies four time limit: 1000 MS | memory limit: 65535 kb difficulty: 3
Description

These days, dummies have been studying stocks. After research, they finally found that the stock laws of XXX company. what's even better is that dummies work out the company's stock price every day to prevent others from discovering its secrets. He decided to buy the company's stock at most once, and now the dumb has listed the stock price. (This is no longer an idiot's problem. He has solved it ). I just want to make it difficult for you. From the stock price list, Can you calculate the maximum amount of money a dumb can earn per share?

Input
The first line is N, indicating N days (less than 100000)
The second row provides the price per share for N days.
Output
Maximum earnings per share
Sample Input
4947 267 359 7717669 735 322 794 397 565 181  
Sample output
504472
# Include <stdio. h> int main () {int day; while (scanf ("% d", & day )! = EOF) {int max = 0, S, sum = 0, x, y; scanf ("% d", & X); Day --; while (day --) {scanf ("% d", & Y); s = Y-X; // sum of the difference between the last item and the previous one <0? Sum = s: Sum + = s; // when sum is less than 0, the value of S is assigned to sum. Otherwise, the sum will continue! Max <sum? Max = sum: Sum = sum; // compare and assign the values of limit to max X = y; // prepare for the next loop} printf ("% d \ n ", max); // The maximum amount of money transferred per share.} return 0 ;}


Nyoj 739 stupid question 4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.