Beginner Free Contest 42 - MAXDIFF

View as PDF

Submit solution

Points: 0.20 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem type
Allowed languages
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch

In case the statement didn't load correctly, you can download the statement here: Statement

Lưu ý: các bạn không nhập, xuất dữ liệu bằng file kể cả khi đề bài có yêu cầu. Đọc, ghi dữ liệu được thực hiện ở stdin và stdout.


Comments

Please read the guidelines before commenting.



  • 0
    YangKlee  commented on Jan. 15, 2025, 3:10 a.m.

    !#include <bits/stdc++.h>

    define ll long long

    define IOS iosbase::syncwith_stdio(false); cin.tie(NULL); cout.tie(NULL);

    define vti vector <int>

    define vtll vector <long long>

    define vtf vector <float>

    define str string

    define el cout << "\n"

    using namespace std; int main() { IOS; int n; cin >> n; vti a(n); int maxdiff = 0; for (int i = 0; i < n; i++) { cin >> a[i]; for (int j = i-1; j >= 0; j-- ) { int diff = abs(a[i] - a[j]); if (diff > maxdiff) maxdiff = diff; } } cout << maxdiff; }


  • 0
    pthtuong29  commented on Jan. 9, 2025, 12:23 p.m.

    Xài *maxelement trừ cho *minelement của mảng hoặc sort rồi in ra arr[arr.size()-1]-arr[0]


  • 0
    Phuong2008  commented on Sept. 3, 2023, 11:55 a.m.

    chạy test đúng nhưng nộp bay mất 6 test là sao vậy mọi người?