# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
912690 | andro | Pismo (COCI18_pismo) | C++14 | 11 ms | 3420 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
vector<int> suf_max(n + 2);
vector<int> suf_min(n + 2, 1e18);
int ans = 1e18;
for(int i = n; i > 0; i--) {
suf_max[i] = max(suf_max[i + 1], a[i]);
suf_min[i] = min(suf_min[i + 1], a[i]);
}
for(int i = n - 1; i > 0; i--) {
ans = min(ans, suf_max[i] - suf_min[i]);
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |