Submission #912690

#TimeUsernameProblemLanguageResultExecution timeMemory
912690androPismo (COCI18_pismo)C++14
0 / 70
11 ms3420 KiB
#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 timeMemoryGrader output
Fetching results...