AcWing 3722. 骑车路线
原题链接
简单
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 1e3 + 10;
int t, n, m, k, l, r, op, x, y, s, e;
int f[N];
void solve() {
while (cin >> n) {
t = 0;
cin >> f[1];
s = f[1];
e = 0;
for (int i = 2; i <= n; i++) {
cin >> f[i];
if (f[i-1] <= f[i]) {
e = f[i];
} else {
t = max(t,e-s);
s = f[i];
e = 0;
}
}
t = max(t,e-s);
cout << t << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}