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
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; }
Xài *maxelement trừ cho *minelement của mảng hoặc sort rồi in ra arr[arr.size()-1]-arr[0]
chạy test đúng nhưng nộp bay mất 6 test là sao vậy mọi người?