QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#111247 | #4995. Highest Hill | PetroTarnavskyi# | TL | 2ms | 3436kb | C++17 | 818b | 2023-06-06 14:42:08 | 2023-06-06 14:42:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<LL> h(n);
LL ans = 0;
FOR (i, 0, n)
cin >> h[i];
FOR (i, 1, n - 1)
{
int j = i - 1;
int k = i + 1;
if (h[j] <= h[i] && h[i] >= h[k])
{
while (j > 0 && h[j - 1] <= h[j]) j--;
while (k < n - 1 && h[k + 1] <= h[k]) k++;
ans = max(ans, min(h[i] - h[j], h[i] - h[k]));
}
}
cout << ans << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3428kb
input:
11 0 1 2 3 4 5 4 3 2 1 0
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3376kb
input:
10 29 85 88 12 52 37 19 86 7 44
output:
67
result:
ok single line: '67'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3384kb
input:
3 2147483647 318000000000 2147483647
output:
315852516353
result:
ok single line: '315852516353'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3436kb
input:
3 1 1 1
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3396kb
input:
7 7 5 7 6 7 6 6
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3384kb
input:
7 8 8 9 8 1 5 8
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 2ms
memory: 3428kb
input:
7 4 10 8 9 6 6 4
output:
2
result:
ok single line: '2'
Test #8:
score: -100
Time Limit Exceeded
input:
200000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...