Problem 2650 --Getting Started - Maximum Profit

2650: Getting Started - Maximum Profit

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $60$ 正确数量 $29$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 STL

Maximum Profit 

You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. 

Write a program which reads values of a currency Rt at a certain time t (t=0,1,2,...n−1), and reports the maximum value of Rj−Ri where j>i.

The first line contains an integer nn. In the following nn lines, Rt (t=0,1,2,...n−1) are given in order.
Print the maximum value in a line.
6
5
3
1
3
4
3
3

2≤ n≤ 200,000

1≤ Rt≤ 10^9

推荐代码 查看2650 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$0 $ms] 心无眠 698462 2021-01-03 22:51:12
内存最少[$2016 $KB] AOJ大管家 437214 2019-06-08 12:59:16
第一AC AOJ大管家 338575 2018-12-05 21:33:59
第一挑战 AOJ大管家 338575 2018-12-05 21:33:59

赛题来源/所属竞赛 会津大学《挑战数据结构与算法》 挑战数据结构与算法

竞赛编号 竞赛名称 竞赛时间 访问比赛