# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
912690 | andro | Pismo (COCI18_pismo) | C++14 | 11 ms | 3420 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |