QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#123697 | #1822. Mountainous Palindromic Subarray | Scarlett_boy | WA | 1ms | 3480kb | C++23 | 864b | 2023-07-13 12:32:28 | 2023-07-13 12:32:31 |
Judging History
answer
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 10;
int n;
void solve() {
cin >> n;
vector<int> a(n + 1, 0);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int ans = 0;
for (int i = 1; i <= n;) {
int j = i;
while (j + 1 <= n && a[j + 1] > a[j]) {
j++;
}
int z = 1;
int len = 1;
while (j + z <= n && j - z >= 1 && a[j + z] == a[j - z]) {
z++;
len += 2;
}
ans = max(ans, len);
i = j + max(1, z - 1);
}
if (ans == 1)cout << -1;
else cout << ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int _ = 1;
// cin >> _;
for (int o = 1; o <= _; o++) solve();
return 0;
}
/*
1
4
4 5 7 9
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3384kb
input:
8 2 1 2 3 2 1 7 8
output:
5
result:
ok answer is '5'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3448kb
input:
5 2 5 8 7 2
output:
-1
result:
ok answer is '-1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3432kb
input:
1 19
output:
-1
result:
ok answer is '-1'
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3480kb
input:
7 1 3 3 6 3 3 1
output:
7
result:
wrong answer expected '3', found '7'