1 条题解

  • 0
    @ 2024-12-8 16:06:37
    #include <iostream>
    #include <vector>
    #include <cmath> 
    
    int main() {
        int n; 
        std::cin >> n;
        
        std::vector<int> distances(n);
        for (int i = 0; i < n; ++i) {
            std::cin >> distances[i];
        }
        
        int max_distance = 0; 
        for (int i = 1; i < n; ++i) {
            int distance = std::abs(distances[i] - distances[i - 1]); 
            if (distance > max_distance) { 
                max_distance = distance;
            }
        }
        std::cout << max_distance << std::endl;
        
        return 0;
    }
    
    • 1

    信息

    ID
    91
    时间
    1000ms
    内存
    256MiB
    难度
    7
    标签
    递交数
    269
    已通过
    65
    上传者