文章

117

粉丝

69

获赞

860

访问

113.6k

头像
骑车路线(模拟) 题解:
P1737 华东师范大学2021年机试题
发布于2025年3月19日 16:43
阅读数 270

#include<iostream>
#include<algorithm>
#include<limits.h>
#include<cmath>
#include<cstring>
#include<vector>
#include<string>
using namespace std;

const int N = 1010;
int p[N];
int n;

int main() 
{
    while(cin >> n)
    {
        int t = N, s = 0, ans = 0;
        for(int i = 1; i <= n; i ++)
        {
            int x; scanf("%d", &x);
            if(x >= s) t = min(t, x), s = x;
            else t = x, s = 0;
            if(s) ans = max(ans, abs(t - s));
        }
        printf("%d\n", ans);
    }
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发