题目链接:Codeforces 463E Caisa and Pylons
题目大意:给定n个位置的高度,0的位置为0,每次移动一步时,需要消耗hi−hi+1的能量,一开始能量为0,过程中能量不能为负,一美元可以买一点能量,问说最小开销。
解题思路:水题,找最大值即可。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main () {
int n, x, ans = 0;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &x);
ans = max(ans, x);
}
printf("%d\n", ans);
return 0;
}